题目:Two elements of a binary search tree (BST) are
swapped by mistake.Recover the tree without changing its structure.Note:A
solution using O(n) space ...
分类:
其他好文 时间:
2014-05-23 11:31:51
阅读次数:
299
MSS(Array[],N)//Where N is the number of
elements in array{sum=0; //current summax-sum=0;//Maximum Sumseq-start=0;//start
of the subsequenceseq-end=0;...
分类:
其他好文 时间:
2014-05-23 11:03:58
阅读次数:
221
戳我去解题Given an array where elements are sorted in
ascending order, convert it to a height balanced
BST.分析:因为BST中序序列是升序的,所以中序遍历序列最中间的元素一定是根节点,然后左右递归构建二叉...
分类:
其他好文 时间:
2014-05-20 11:38:16
阅读次数:
233
.val()works on input elements (or any element
with a value attribute?) and.text()will not work on input elements..val()gets
the value of the input ele...
分类:
Web程序 时间:
2014-05-19 12:14:34
阅读次数:
382
【题目】
Given an array and a value, remove all instances of that value in place and return the new length.
The order of elements can be changed. It doesn't matter what you leave beyond the new length.
【题意】
删除数组中指定的值。不关心在新数组的后面即数组尾部留下了什么值。
【思路】
思路同Remo...
分类:
其他好文 时间:
2014-05-18 14:53:56
阅读次数:
208
4Sum
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target....
分类:
其他好文 时间:
2014-05-18 13:49:09
阅读次数:
306
【题目】
Given an array S of n integers, are there elements a, b, c, and d in S such that a + b + c + d = target? Find all unique quadruplets in the array which gives the sum of target.
Note:
Elements in a quadruplet (a,b,c,d) must be in non-descending ord...
分类:
其他好文 时间:
2014-05-18 08:46:04
阅读次数:
227
【题目】
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives the sum of zero.
Note:
Elements in a triplet (a,b,c) must be in non-descending order. (ie, a ≤ b ≤ c)
The so...
分类:
其他好文 时间:
2014-05-18 03:15:50
阅读次数:
287
Given an unsorted array of integers, find the
length of the longest consecutive elements sequence.For example,Given[100, 4,
200, 1, 3, 2],The longest ...
分类:
其他好文 时间:
2014-05-18 01:52:45
阅读次数:
317
Two elements of a binary search tree (BST) are
swapped by mistake.Recover the tree without changing its structure.Note:A
solution using O(n) space is ...
分类:
其他好文 时间:
2014-05-17 14:45:17
阅读次数:
290