Given a binary tree, return thelevel ordertraversal of its nodes' values. (ie, from left to right, level by level).For example:Given binary tree{3,9,2...
分类:
其他好文 时间:
2015-07-27 22:36:15
阅读次数:
121
Binary Tree? CLRS We define binary trees recursively. A binary tree T is a structure defined on a finite set of nodes that either contains no nodes, o...
分类:
其他好文 时间:
2015-07-27 20:51:58
阅读次数:
209
Given a 2D binary matrix filled with 0's and 1's, find the largest square containing all 1's and return its area.For example, given the following matrix:1 0 1 0 0
1 0 1 1 1
1 1 1 1 1
1 0 0 1 0
Return ...
分类:
其他好文 时间:
2015-07-27 19:12:53
阅读次数:
106
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 ancestor is defined betwee...
分类:
其他好文 时间:
2015-07-27 18:48:41
阅读次数:
80
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1].No...
分类:
其他好文 时间:
2015-07-27 18:35:11
阅读次数:
98
Given a binary tree, return theinordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[1,3,2].Note...
分类:
其他好文 时间:
2015-07-27 14:49:21
阅读次数:
101
Given a binary tree, return thepostordertraversal of its nodes' values.For example:Given binary tree{1,#,2,3}, 1 \ 2 / 3return[3,2,1]./*...
分类:
其他好文 时间:
2015-07-27 14:33:39
阅读次数:
89
二分查找很简单,原理就不说了。STL中关于二分查找的函数有三个lower_bound 、upper_bound 、binary_search 。这三个函数都运用于有序区间(当然这也是运用二分查找的前提)。
其中如果寻找的value存在,那么lower_bound返回一个迭代器指向其中第一个这个元素。upper_bound返回一个迭代器指向其中最后一个这个元素的下一个位置(明确点说就...
分类:
其他好文 时间:
2015-07-27 13:18:28
阅读次数:
203
226
Invert Binary Tree
36.2%
Easy
Invert a binary tree.
4
/ 2 7
/ \ / 1 3 6 9
to
4
/ 7 2
/ \ / 9 6 3 1
对的,这就是前阵子homebrew大神...
分类:
其他好文 时间:
2015-07-27 13:14:34
阅读次数:
92
Java提供的位运算符有:左移( >) 、无符号右移(>>>) 、位与(&)、位或( |)、位非(~)、位异或(^),除了位非( ~ )是一元操作符外,其它的都是二元操作符。print Binary:System.out.printIn(Integer.toBinaryString(2)); //....
分类:
编程语言 时间:
2015-07-27 13:03:33
阅读次数:
148