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.
难度系数:
容易
实现
ListN...
分类:
其他好文 时间:
2015-02-11 16:44:16
阅读次数:
117
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...
分类:
其他好文 时间:
2015-02-11 16:19:05
阅读次数:
117
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.
Example
Tags Expand
Recursion Linked
List
解题思路:
思路一:平衡树调整。第一步建立一个单向树...
分类:
其他好文 时间:
2015-02-11 14:47:17
阅读次数:
139
题目 这道题是链表的简单应用,将两个有序链表合成一个有序链表。 思路是:表一,表二各取两个对象,分别指向current和next,进行交叉比较排序。Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nod...
分类:
其他好文 时间:
2015-02-11 12:48:27
阅读次数:
148
原文地址:http://www.codeproject.com/Articles/3217/An-STL-compliant-sorted-vector 最近在看sorted vectored的一些东西,自己封装了一个sorted vector类型,后来找到了codeproject上的一...
分类:
其他好文 时间:
2015-02-11 12:35:13
阅读次数:
158
STL set能保证最坏情况下的查找和插入效率,logN。但是维护红黑树开销较大。set内的元素按照一定的逻辑顺序组织,查找、插入等操作的结果都和排序规则有关。 适合STL set的情况为: 1、集合很大,以至于O(N)远大于O(longN)。2、查找和插入的次数一样多,且需要考虑插入的效...
分类:
其他好文 时间:
2015-02-11 10:52:07
阅读次数:
153
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 mightbecome 4 5 6 7 0 1 2).
Find the minimum element.
You may assume no duplicate exists in the array...
分类:
其他好文 时间:
2015-02-11 09:27:00
阅读次数:
166
Merge k sorted
linked lists and return it as one sorted list. Analyze and describe its complexity.
题意:将k个已经排好序的链表合并成一个
思路:用到优先队列比较简单。
/**
* Definition for singly-linked list.
* struct ListNod...
分类:
其他好文 时间:
2015-02-10 16:47:11
阅读次数:
124
Suppose a sorted array is rotated at some pivot unknown to you beforehand.
(i.e., 0 1 2 4 5 6 7 might become 4
5 6 7 0 1 2).
Find the minimum element.
The array may contain duplicates.
解...
分类:
其他好文 时间:
2015-02-10 15:22:51
阅读次数:
195
Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first
two lists.
题意:将两个有序的链表合并成一个链表
思路:每次比较链表头就行了,把比较小的插入新的链表中
/**
...
分类:
其他好文 时间:
2015-02-10 15:19:37
阅读次数:
132