Given a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2->3->4->5, and n = 2. After re...
分类:
其他好文 时间:
2014-12-05 07:05:34
阅读次数:
191
本文是在学习中的总结,欢迎转载但请注明出处:http://blog.csdn.net/pistolove/article/details/41728739
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.
思路:
(1...
分类:
其他好文 时间:
2014-12-04 21:44:57
阅读次数:
185
Partition List Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x.You should...
分类:
其他好文 时间:
2014-12-04 19:57:46
阅读次数:
204
Reverse Linked List IIReverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return...
分类:
其他好文 时间:
2014-12-04 17:16:00
阅读次数:
183
2.6 给定一个有环链表,实现一个算法返回环路的开头结点。类似leetcode中Linked List Cycle IIC++实现代码:#include#includeusing namespace std;struct ListNode{ int val; ListNode *next...
分类:
其他好文 时间:
2014-12-04 00:43:56
阅读次数:
250
Sort a linked list using insertion sort.链表的插入排序,算法可参看数组插入排序,不同之处在于查找插入点时,链表要从前往后查找。代码如下: 1 ListNode *insertionSortList(ListNode *head) 2 { 3 ...
分类:
其他好文 时间:
2014-12-03 23:07:23
阅读次数:
155
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?使用双指针fast和slow,fast每次走两步,slow每次走一步,如果fast追...
分类:
其他好文 时间:
2014-12-03 23:04:47
阅读次数:
287
Given a linked list, reverse the nodes of a linked listkat a time and return its modified list.If the number of nodes is not a multiple ofkthen left-o...
分类:
其他好文 时间:
2014-12-03 22:52:34
阅读次数:
114
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:
其他好文 时间:
2014-12-03 22:44:08
阅读次数:
134
Given a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the origi...
分类:
其他好文 时间:
2014-12-03 22:43:18
阅读次数:
153