Reverse a linked list from position m to n. Do it in-place and in one-pass.
For example:
Given
1->2->3->4->5->NULL, m = 2 and n = 4,
return
1->4->3->2->5->NULL.
Note:
Given m, n satisfy the f...
分类:
其他好文 时间:
2014-11-04 21:14:42
阅读次数:
157
/**
* Definition for singly-linked list with a random pointer.
* struct RandomListNode {
* int label;
* RandomListNode *next, *random;
* RandomListNode(int x) : label(x), next(NULL), ...
分类:
其他好文 时间:
2014-11-04 11:11:48
阅读次数:
216
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-11-04 10:40:26
阅读次数:
143
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. 1 /** 2 * Definition for singly-linked ....
分类:
其他好文 时间:
2014-11-03 23:53:07
阅读次数:
185
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->4->5, and n = 2.
After removing the second node from the end, the linked ...
分类:
其他好文 时间:
2014-11-03 21:02:22
阅读次数:
182
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:
其他好文 时间:
2014-11-03 20:48:12
阅读次数:
249
Given a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?思路:快慢指针的应用。快慢指针指的是移动的步长,即每次向前移动的快慢。例如可以让快指...
分类:
其他好文 时间:
2014-11-03 20:42:18
阅读次数:
204
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->3->NULL.
看到这个题目感到奇怪的是为什么是“右旋”,而不是“左旋...
分类:
其他好文 时间:
2014-11-02 13:54:27
阅读次数:
225
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-...
分类:
其他好文 时间:
2014-11-02 13:41:39
阅读次数:
168
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 left-out nodes in the end should remain as it is.
...
分类:
其他好文 时间:
2014-11-02 09:27:14
阅读次数:
276