Sort a linked list inO(nlogn) time using
constant space complexity./** * Definition for singly-linked list. * struct
ListNode { * int val; * L...
分类:
其他好文 时间:
2014-06-06 20:01:30
阅读次数:
333
Given a sorted linked list, delete all
duplicates such that each element appear onlyonce.For
example,Given1->1->2, return1->2.Given1->1->2->3->3,
retu...
分类:
其他好文 时间:
2014-06-06 14:54:28
阅读次数:
221
Sort a linked list using insertion sort./** *
Definition for singly-linked list. * struct ListNode { * int val; * ListNode
*next; * ListNo...
分类:
其他好文 时间:
2014-06-06 10:39:38
阅读次数:
212
Given a sorted linked list, delete all
duplicates such that each element appear onlyonce.For
example,Given1->1->2, return1->2.Given1->1->2->3->3,
retu...
分类:
其他好文 时间:
2014-06-06 07:00:36
阅读次数:
269
Given a sorted linked list, delete all nodes
that have duplicate numbers, leaving onlydistinctnumbers from the original
list.For example,Given1->2->3-...
分类:
其他好文 时间:
2014-06-06 06:57:18
阅读次数:
271
Given a linked list, reverse the nodes of a
linked list k at a time and return its modified list. If the number of nodes is
not a multiple of k then l...
分类:
其他好文 时间:
2014-06-05 22:13:19
阅读次数:
391
题目链接又是一个考察对链表基本操作的题目附上代码: 1 /** 2 * Definition for
singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 *
Lis...
分类:
其他好文 时间:
2014-06-02 12:00:52
阅读次数:
226
Given a linked list, determine if it has a
cycle in it.Follow up:Can you solve it without using extra
space?求链表是否有环的问题,要考虑链表为空的情况,定义一个快指针和一个慢指针,如果快指针和...
分类:
其他好文 时间:
2014-06-02 08:05:16
阅读次数:
255
Given a linked list, return the node where the
cycle begins. If there is no cycle, returnnull.Follow up:Can you solve it
without using extra space?借用博...
分类:
其他好文 时间:
2014-06-02 07:32:33
阅读次数:
291
Sort ListSort a linked list inO(nlogn) time
using constant space
complexity.要求时间复杂度为O(nlogn),那么不能用quickSort了(最坏O(n^2)),所以使用mergeSort.通常写排序算法都是基于数组的,这题...
分类:
其他好文 时间:
2014-06-02 06:29:51
阅读次数:
192