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 pretty straight forward. Could you devis...
分类:
其他好文 时间:
2014-08-29 21:28:08
阅读次数:
313
Young cryptoanalyst Georgie is investigating different schemes of generating random integer numbers
ranging from 0 to m - 1.
He thinks that standard random number generators are not good enough, s...
分类:
其他好文 时间:
2014-08-29 21:26:38
阅读次数:
317
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 mat...
分类:
其他好文 时间:
2014-08-29 02:35:13
阅读次数:
203
LeetCode: Recover Binary Search TreeTwo elements of a binary search tree (BST) are swapped by mistake.Recover the tree without changing its structure....
分类:
其他好文 时间:
2014-08-28 23:58:36
阅读次数:
385
给定一个整数数组(长度不小于3) 和 一个目标值, 从数组中找出3个元素, 使得它们的和与目标值最接近, 返回这个和. 可以认为每个输入的组合都是只有唯一解的.解法思路参考: Finding three elements in an array whose sum is closest to an ...
分类:
其他好文 时间:
2014-08-28 22:38:06
阅读次数:
212
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-08-28 19:33:55
阅读次数:
266
SubsetsGiven a set of distinct integers,S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must...
分类:
其他好文 时间:
2014-08-28 17:58:05
阅读次数:
356
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...
分类:
其他好文 时间:
2014-08-28 13:22:49
阅读次数:
177
Convert Sorted Array to Binary Search TreeGiven an array where elements are sorted in ascending order, convert it to a height balanced BST.方法:将有序数组转为平...
分类:
其他好文 时间:
2014-08-27 23:17:18
阅读次数:
278
每一行都建一个线段树。。。。
Fast Matrix Operations
There is a matrix containing at most 106 elements divided into r rows and c columns. Each element has a
location (x,y) where 1
1 x1 y1 x2 y2 v
...
分类:
其他好文 时间:
2014-08-27 18:50:58
阅读次数:
199