Given a binary tree, flatten it to a linked list in-place. For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened ...
分类:
其他好文 时间:
2014-11-08 13:25:14
阅读次数:
119
Sort a linked list in O(n log n) time using constant space complexity.解决这个问题让我很是纠结,能不能用快速排序呢?我试了很多次,结果总是超时,甚至在用系统自带的stl时也是这样。为什么呢?事后想想,快速排序没有充分利用链表的连贯...
分类:
其他好文 时间:
2014-11-08 13:20:59
阅读次数:
245
这次是做题最顺的一次,提交两次,耗时1分钟就ac了,错的那次是因为没有考虑到空链表,少了一个判断。/** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next...
分类:
其他好文 时间:
2014-11-08 07:04:13
阅读次数:
152
Remove Nth Node From End of ListGiven a linked list, remove thenthnode from the end of list and return its head.For example, Given linked list: 1->2.....
分类:
其他好文 时间:
2014-11-06 21:49:31
阅读次数:
217
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-06 19:29:56
阅读次数:
149
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-11-06 16:45:28
阅读次数:
111
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-11-06 14:30:36
阅读次数:
151
1、题目 - Linked List Cycle IIGiven a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it w...
分类:
编程语言 时间:
2014-11-06 01:56:43
阅读次数:
221
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-11-05 08:04:14
阅读次数:
177
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,
Given
1->2->3->3->4->4->5, return
1->2->5.
Given
1...
分类:
其他好文 时间:
2014-11-04 22:55:40
阅读次数:
300