DescriptionThe Fibonacci sequence is the sequence of numbers such that every element is equal to the sum of the two previous elements, except for the ...
分类:
其他好文 时间:
2014-10-07 13:38:23
阅读次数:
169
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-10-07 01:22:02
阅读次数:
270
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-10-06 18:43:20
阅读次数:
201
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 ...
分类:
其他好文 时间:
2014-10-05 19:14:28
阅读次数:
173
Replacing an element of a list with another:% lreplace {a b c d e} 1 1 fooa foo c d eReplacing two elements of a list with three:% lreplace {a b c d e...
分类:
其他好文 时间:
2014-10-04 13:08:16
阅读次数:
162
Given 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 not contain duplicate subsets.
For example,
I...
分类:
其他好文 时间:
2014-10-03 22:24:55
阅读次数:
273
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* Lis...
分类:
其他好文 时间:
2014-10-03 17:21:45
阅读次数:
167
Given an array where elements are sorted in ascending order, convert it to a height balanced BST.
/**
* Definition for binary tree
* struct TreeNode {
* int val;
* TreeNode *left;
* ...
分类:
其他好文 时间:
2014-10-03 15:40:04
阅读次数:
186
在要排序的一组数列中,选出最小(或者最大)的一个数与第1个位置的数交换;然后在剩下的数当中再找最小(或者最大)的与第2个位置的数交换,依次类推,直到第n-1个元素(倒数第二个数)和第n个元素(最后一个数)比较为止。function sort(elements){ for(i = 0; i < el....
分类:
编程语言 时间:
2014-09-30 23:17:30
阅读次数:
220
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 consecutive elements sequence is [1, 2, 3...
分类:
其他好文 时间:
2014-09-30 21:48:20
阅读次数:
179