- 博客(94)
- 资源 (1)
- 收藏
- 关注
转载 292. Nim Game
题目:尼姆游戏You are playing the following Nim Game with your friend: There is a heap of stones on the table, each time one of you take turns to remove 1 to 3 stones. The one who removes the last ston
2016-07-31 22:50:15 358
转载 319. Bulb Switcher
题目:灯泡开关There are n bulbs that are initially off. You first turn on all the bulbs. Then, you turn off every second bulb. On the third round, you toggle every third bulb (turning on if it's off or
2016-07-31 22:33:53 264
转载 220. Contains Duplicate III
题目:包含重复值3Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] andnums[j] is at most t and the difference be
2016-07-31 22:15:30 433
转载 307. Range Sum Query - Mutable
题目:区域和检索-可变Given an integer array nums, find the sum of the elements between indices i and j (i ≤ j), inclusive.The update(i, val) function modifies nums by updating the element at index i
2016-07-31 16:13:06 311
转载 284. Peeking Iterator
题目:顶端迭代器Given an Iterator class interface with methods: next() and hasNext(), design and implement a PeekingIterator that support the peek()operation -- it essentially peek() at the element
2016-07-31 15:09:38 438
转载 130. Surrounded Regions
题目:包围区域Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'.A region is captured by flipping all 'O's into 'X's in that surrounded region.For
2016-07-31 12:19:12 316
转载 310. Minimum Height Trees
题目:最小高度树For a undirected graph with tree characteristics, we can choose any node as the root. The result graph is then a rooted tree. Among all possible rooted trees, those with minimum heig
2016-07-31 11:18:21 304
转载 210. Course Schedule II
题目:课程表2There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is
2016-07-31 10:55:03 362
转载 207. Course Schedule
题目:课程表There are a total of n courses you have to take, labeled from 0 to n - 1.Some courses may have prerequisites, for example to take course 0 you have to first take course 1, which is e
2016-07-30 23:33:54 1308
转载 200. Number of Islands
题目:岛屿数量Given a 2d grid map of '1's (land) and '0's (water), count the number of islands. An island is surrounded by water and is formed by connecting adjacent lands horizontally or vertically.
2016-07-30 22:56:48 284
转载 133. Clone Graph
题目:无向图复制Clone an undirected graph. Each node in the graph contains a label and a list of its neighbors.OJ's undirected graph serialization:Nodes are labeled uniquely.We use # as a separa
2016-07-30 21:46:24 521
转载 332. Reconstruct Itinerary
题目:重建行程单Given a list of airline tickets represented by pairs of departure and arrival airports [from, to], reconstruct the itinerary in order. All of the tickets belong to a man who departs fr
2016-07-30 16:00:47 581
转载 129. Sum Root to Leaf Numbers
题目:根到叶子节点数字之和Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number.An example is the root-to-leaf path 1->2->3 which represents the number 12
2016-07-30 15:02:51 256
转载 236. Lowest Common Ancestor of a Binary Tree
题目:二叉树的最小共同父节点Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree.According to the definition of LCA on Wikipedia: “The lowest common ancestor is defi
2016-07-30 14:26:45 338
转载 199. Binary Tree Right Side View
题目:二叉树右侧视图Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom.For example:Given the following bina
2016-07-30 11:30:59 894
转载 337. House Robber III
题目:入室盗贼3The thief has found himself a new place for his thievery again. There is only one entrance to this area, called the "root." Besides the root, each house has one and only one parent house
2016-07-30 11:00:35 325
转载 116. Populating Next Right Pointers in Each Node
题目:填充每个节点的指向右边邻居的指针Given a binary tree struct TreeLinkNode { TreeLinkNode *left; TreeLinkNode *right; TreeLinkNode *next; }Populate each next pointer to point
2016-07-30 10:09:55 330
转载 114. Flatten Binary Tree to Linked List
题目:二叉树展开成链表Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened tree should loo
2016-07-29 15:47:37 282
转载 113. Path Sum II
题目:二叉树路径和2Given a binary tree and a sum, find all root-to-leaf paths where each path's sum equals the given sum.For example:Given the below binary tree and sum = 22, 5
2016-07-29 14:52:51 278
转载 98. Validate Binary Search Tree
题目:验证二叉搜索树Given a binary tree, determine if it is a valid binary search tree (BST).Assume a BST is defined as follows:The left subtree of a node contains only nodes with keys less than t
2016-07-29 14:21:37 1329
转载 108. Convert Sorted Array to Binary Search Tree
题目:有序数组转为二叉搜索树Given an array where elements are sorted in ascending order, convert it to a height balanced BST.题意:给定一个已经按照递增排序好的数组,将该有序数组转换为一棵高度平衡的二叉搜索树。思路:二叉搜索树的特点是,每个节点都满足左节点代码
2016-07-29 11:22:44 302
转载 226. Invert Binary Tree
题目:翻转二叉树Invert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1题意:如上如所示,将给定的二叉树按照根节点中间对称线进行翻转,左子树与右子树值相互对调。转载地址:
2016-07-29 10:58:19 219
转载 257. Binary Tree Paths
题目:二叉树路径Given a binary tree, return all root-to-leaf paths.For example, given the following binary tree: 1 / \2 3 \ 5All root-to-leaf paths are:["1->2->5", "1->
2016-07-29 10:23:06 241
转载 111. Minimum Depth of Binary Tree
题目:最小树深Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.题意:给定一棵二叉树,找到最小树深
2016-07-29 09:49:18 256
转载 112. Path Sum
题目:二叉树路径和Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all the values along the path equals the given sum.For example:Given the below binar
2016-07-28 16:11:15 296
转载 100. Same Tree
题目:相同树Given two binary trees, write a function to check if they are equal or not.Two binary trees are considered equal if they are structurally identical and the nodes have the same value.
2016-07-28 15:43:04 228
转载 107. Binary Tree Level Order Traversal II
题目:二叉树层序遍历2Given a binary tree, return the bottom-up level order traversal of its nodes' values. (ie, from left to right, level by level from leaf to root).For example:Given binary tree [3
2016-07-28 15:26:32 249
转载 104. Maximum Depth of Binary Tree
题目:二叉树的最大深度Given a binary tree, find its maximum depth.The maximum depth is the number of nodes along the longest path from the root node down to the farthest leaf node.题意:给定一个二叉树,找到该树
2016-07-28 14:55:55 239
转载 102. Binary Tree Level Order Traversal
题目:二叉树层序遍历Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree [3,9,20,null,null,15,7],
2016-07-28 14:29:47 251
转载 101. Symmetric Tree
题目:对称树Given a binary tree, check whether it is a mirror of itself (ie, symmetric around its center).For example, this binary tree [1,2,2,3,4,4,3] is symmetric: 1 / \ 2 2 / \ / \
2016-07-28 13:53:24 267
转载 110. Balanced Binary Tree
题目:平衡二叉树Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every no
2016-07-28 11:53:03 241
转载 235. Lowest Common Ancestor of a Binary Search Tree
题目:二叉搜索树的最小共同父节点Given a binary search tree (BST), find the lowest common ancestor (LCA) of two given nodes in the BST.According to the definition of LCA on Wikipedia: “The lowest common ance
2016-07-28 11:14:52 217
转载 260. Single Number III
题目:单个数字3Given an array of numbers nums, in which exactly two elements appear only once and all the other elements appear exactly twice. Find the two elements that appear only once.For exam
2016-07-28 10:43:24 272
转载 201. Bitwise AND of Numbers Range
题目:数字范围位相与Given a range [m, n] where 0 For example, given the range [5, 7], you should return 4.题意:给定一个范围[m,n],0 转载:http://www.cnblogs.com/grandyang/p/4431646.html思路一:从题目中给的例
2016-07-28 09:42:05 382
转载 137. Single Number II
题目:单个数字2Given an array of integers, every element appears three times except for one. Find that single one.Note:Your algorithm should have a linear runtime complexity. Could you implement
2016-07-27 23:22:17 258
转载 318. Maximum Product of Word Lengths
题目:单词长度的最大积Given a string array words, find the maximum value of length(word[i]) * length(word[j]) where the two words do not share common letters. You may assume that each word will contain o
2016-07-27 22:30:13 248
转载 342. Power of Four
题目:判断是否是4的N次方Given an integer (signed 32 bits), write a function to check whether it is a power of 4.Example:Given num = 16, return true. Given num = 5, return false.Follow up: Could y
2016-07-27 22:01:09 319
转载 190. Reverse Bits
题目:逆位Reverse bits of a given 32 bits unsigned integer.For example, given input 43261596 (represented in binary as 00000010100101000001111010011100), return 964176192 (represented in binary a
2016-07-27 21:22:26 242
转载 371. Sum of Two Integers
题目:两个整数的和Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -.Example:Given a = 1 and b = 2, return 3.题意:计算两个整数a和b的和,但是不允许使用+、-计算操作符。思
2016-07-26 23:20:06 277
转载 191. Number of 1 Bits
题意:1的位数Write a function that takes an unsigned integer and returns the number of ’1' bits it has (also known as the Hamming weight).For example, the 32-bit integer ’11' has binary represen
2016-07-26 22:43:36 264
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人