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 the original relative order of the nodes in each of...
分类:
其他好文 时间:
2014-11-14 17:50:06
阅读次数:
137
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.
Your algorithm should use only constant space. Y...
分类:
其他好文 时间:
2014-11-14 14:22:50
阅读次数:
164
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-11-14 10:29:38
阅读次数:
157
Given a linked list, swap every two adjacent nodes and return its head.For example,Given1->2->3->4, you should return the list as2->1->4->3.Your algor...
分类:
其他好文 时间:
2014-11-14 08:08:24
阅读次数:
197
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 the original relative order of the nodes in each of...
分类:
其他好文 时间:
2014-11-13 14:45:51
阅读次数:
172
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up:Can you solve it without using extra space?怎...
分类:
其他好文 时间:
2014-11-13 00:20:11
阅读次数:
281
Problem Description: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 mul...
分类:
其他好文 时间:
2014-11-12 22:33:46
阅读次数:
201
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.For e...
分类:
其他好文 时间:
2014-11-12 19:42:37
阅读次数:
186
题目描述:
Given a linked list, return the node where the cycle begins. If there is no cycle, return null.
Follow up:
Can you solve it without using extra space?
思路:
设置一个快指针fast,一个慢指针slow。快指...
分类:
其他好文 时间:
2014-11-11 16:41:06
阅读次数:
179
题目描述:
Given a linked list, determine if it has a cycle in it.
Follow up:
Can you solve it without using extra space?
思路:初始化一个快指针fast,一个慢指针slow。快指针一次移动两个单位,慢指针一次移动一个单位。如果链表有环,则两指针必然会相遇。否则若fas...
分类:
其他好文 时间:
2014-11-11 16:40:35
阅读次数:
208