Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values.
For example,
Given {1,2,3,4}, reorder itto {1,4,...
分类:
其他好文 时间:
2014-11-17 10:45:06
阅读次数:
179
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-11-14 14:22:50
阅读次数:
164
树(Tree)是n(n>=0)个相同类型的数据元素的有限集合。树中的数据元素叫结点(Node)。n=0的树称为空树(Empty Tree);对于n>0的任意非空树T有:
1.有且只有一个特殊的结点称为树的根(Root)结点,根没有前驱结点。
2.若n>1,则除根结点外,其余结点被分成了m(m>0)个互不相交的集合T1,T2,T3,...Tm,其中每个集合Ti(1
由树的定义可知,...
Bloom Filters Ref[1]1. 简介Bloom filter(布隆过滤器;有更好的或正确的翻译,告诉我) 是一个数据结构,该数据结构快速并且内存高效,它可以告诉你某个元素是否在集合中。作为高效的代价,Bloom filter是存在概率的数据结构:它告诉我们某个元素一定不在集合中,或者可...
分类:
其他好文 时间:
2014-10-14 19:48:49
阅读次数:
142
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 binary...
分类:
其他好文 时间:
2014-09-15 17:54:12
阅读次数:
229
Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given 1->2->3->4->5->NULL, m = 2 and n = 4,
return 1->4->3->2->5->NULL.
Note...
分类:
其他好文 时间:
2014-09-09 18:23:49
阅读次数:
222
Combination Sum
Given a set of candidate numbers (C) and a target number (T),
find all unique combinations in C where the candidate numbers sums to T.
The same repeated number may be chosen fro...
分类:
其他好文 时间:
2014-09-02 17:48:05
阅读次数:
244
Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once.
For example,
Given 1->1->2, return 1->2.
Given 1->1->2->3->3, r...
分类:
其他好文 时间:
2014-09-01 17:42:53
阅读次数:
195
Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?
Would this affect the run-time complexity? How and why?
Write a function to determine if a given target is in the...
分类:
其他好文 时间:
2014-08-26 17:19:16
阅读次数:
191
Follow up for N-Queens problem.
Now, instead outputting board configurations, return the total number of distinct solutions.
Java Solutions( Refer to blog
http://blog.csdn.net/mbh_199...
分类:
其他好文 时间:
2014-08-25 19:22:11
阅读次数:
207