欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Rotate List
Given a list, rotate the list to the right by k places, where k is non-negative.
For example:
Given 1->2->3->4->5->NULL and k = 2,
return 4->5->1->2->...
分类:
其他好文 时间:
2015-02-15 10:48:19
阅读次数:
166
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Merge k Sorted Lists
Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
//堆可以用来解决这个问题。
//C++的STL中priority_queue,...
分类:
其他好文 时间:
2015-02-15 10:47:40
阅读次数:
134
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Reorder List
Given a singly linked list L: L0→L1→…→Ln-1→Ln,
reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→…
You must do this in-place without altering the nodes' values....
分类:
其他好文 时间:
2015-02-15 10:47:12
阅读次数:
155
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single dig...
分类:
其他好文 时间:
2015-02-14 17:35:31
阅读次数:
201
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
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 preserve th...
分类:
其他好文 时间:
2015-02-14 17:35:09
阅读次数:
195
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Sort List
Sort a linked list in O(n log n) time using constant space complexity.
// 归并排序法:在动手之前一直觉得空间复杂度为常量不太可能,因为原来使用归并时,都是 O(N)的,需要复制出相等的空间来进行赋值归并。对于链表,实际...
分类:
其他好文 时间:
2015-02-14 17:34:48
阅读次数:
166
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢...
分类:
其他好文 时间:
2015-02-14 16:16:16
阅读次数:
131
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Swap Nodes in Pairs
Given a linked list, swap every two adjacent nodes and return its head.
For example,
Given 1->2->3->4, you should return the list as 2->1->4->3...
分类:
其他好文 时间:
2015-02-13 11:44:24
阅读次数:
127
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head.
For example,
Given linked list: 1->2->3-...
分类:
其他好文 时间:
2015-02-13 11:43:14
阅读次数:
113
欢迎大家阅读参考,如有错误或疑问请留言纠正,谢谢
Intersection of Two Linked Lists
Write a program to find the node at which the intersection of two singly linked lists begins.
For example, the following two linked...
分类:
其他好文 时间:
2015-02-13 11:42:29
阅读次数:
138