Remove Duplicates from Sorted List I
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...
分类:
其他好文 时间:
2014-10-11 16:50:15
阅读次数:
206
Remove Duplicates from Sorted Array I
Given a sorted array, remove the duplicates in place such that each element appear only once and return the new length.
Do not allocate extra space for an...
分类:
其他好文 时间:
2014-10-11 16:19:56
阅读次数:
140
Search for a Range
Total Accepted: 21480 Total
Submissions: 78454My Submissions
Given a sorted array of integers, find the starting and ending position of a given target value.
Your algo...
分类:
其他好文 时间:
2014-10-11 00:15:07
阅读次数:
197
There are two sorted arrays A and B of size m and n respectively. Find the median of the two sorted arrays. The overall run time complexity should be....
分类:
其他好文 时间:
2014-10-10 23:59:54
阅读次数:
226
题意:一个已经排序好的数组,被按某个位置旋转了一次,给定一个值target,在该旋转后的数组里查找该值。
思路:二分查找
难点在于确定往数组的哪一半段继续二分查找
设起点、中间点、终点分别为 start、middle、end (采用前闭后开的区间表示方法
如果target = A[middle] return middle
如果A[middle] >= A[start],则[start,...
分类:
其他好文 时间:
2014-10-10 23:15:44
阅读次数:
219
Search in Rotated Sorted Array II
Total Accepted: 18500 Total
Submissions: 59945My Submissions
Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?
Would this...
分类:
其他好文 时间:
2014-10-10 21:35:14
阅读次数:
239
题目:Given a sorted array, remove the duplicates in place such that each element appear onlyonceand return the new length.Do not allocate extra space fo...
分类:
其他好文 时间:
2014-10-10 20:19:34
阅读次数:
176
Search in Rotated Sorted Array II
Total Accepted: 18488 Total
Submissions: 59914My Submissions
Follow up for "Search in Rotated Sorted Array":
What if duplicates are allowed?
Would this...
分类:
其他好文 时间:
2014-10-10 17:26:24
阅读次数:
122
BST的中序遍历是一个sorted-array,再构造回去成一个BST,先将中间的元素作为根节点,这个节点的左右分别是左子树和右子树。如此递归地进行即可。...
分类:
其他好文 时间:
2014-10-10 02:19:43
阅读次数:
173