Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or...
分类:
其他好文 时间:
2014-11-26 20:34:57
阅读次数:
238
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, return 1->2->3.
#include
#include
...
分类:
其他好文 时间:
2014-11-26 18:59:03
阅读次数:
155
给出一个已排序的数组,将其转化为二叉查找树(BST)。思路:取数组中间元素为根结点的value,则数组左侧、右侧分别为BST的左子树、右子树。递归可求解。代码如下: 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * ...
分类:
其他好文 时间:
2014-11-26 18:13:30
阅读次数:
206
Given two sorted integer arrays A and B, merge B into A as one sorted array.
Note:
You may assume that A has enough space (size that is greater or equal to m + n) to hold additional elements from ...
分类:
其他好文 时间:
2014-11-26 16:29:34
阅读次数:
164
Follow up for "Search in Rotated Sorted Array":What ifduplicatesare allowed?Would this affect the run-time complexity? How and why?Write a function to...
分类:
其他好文 时间:
2014-11-26 13:45:50
阅读次数:
179
Suppose a sorted array is rotated at some pivot unknown to you beforehand.(i.e.,0 1 2 4 5 6 7might become4 5 6 7 0 1 2).You are given a target value t...
分类:
其他好文 时间:
2014-11-26 11:12:08
阅读次数:
122
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 another array, you must do this in place with...
分类:
其他好文 时间:
2014-11-25 23:49:04
阅读次数:
241
问题描述:
Given a set of non-overlapping intervals, insert a new interval into the intervals (merge if necessary).
You may assume that the intervals were initially sorted according to their start time...
分类:
其他好文 时间:
2014-11-25 23:40:58
阅读次数:
248
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.分析:我们比较熟悉由一个sorted array生成一个BST,不同的是这里的数据...
分类:
其他好文 时间:
2014-11-25 23:01:58
阅读次数:
213
Given two sorted integer arrays A and B, merge B into A as one sorted array.Note:You may assume that A has enough space (size that is greater or equal...
分类:
其他好文 时间:
2014-11-25 16:00:36
阅读次数:
165