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-08-01 13:45:32
阅读次数:
163
迭代器模式是设计模式中行为模式(behavioral pattern)的一个例子,他是一种简化对象间通讯的模式,也是一种非常容易理解和使用的模式。简单来说,迭代器模式使得你能够获取到序列中的所有元素而不用关心是其类型是array,list,linked list或者是其他什么序列结构。这一点使得.....
分类:
其他好文 时间:
2014-08-01 12:59:11
阅读次数:
295
LeetCode: 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 ...
分类:
其他好文 时间:
2014-08-01 10:41:51
阅读次数:
224
题目:Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.题解:之前做过一道是从sorted array转换到BinarySearc....
分类:
编程语言 时间:
2014-08-01 04:54:21
阅读次数:
310
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-08-01 04:40:11
阅读次数:
166
centos启动时,提示错误: 1 /dev/mapper/VolGroup-lv_root contains a file system with errors,check forced. 2 /dev/mapper/VolGroup-lv_root: 3 Inodes that were par...
分类:
其他好文 时间:
2014-07-31 23:29:00
阅读次数:
3182
本文为senlie原创,转载请保留此地址:http://blog.csdn.net/zhengsenlieSwap Nodes in PairsTotal Accepted:12511Total Submissions:39302Given a linked list, swap every two...
分类:
其他好文 时间:
2014-07-31 23:26:40
阅读次数:
307
1 public boolean hasCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ...
分类:
其他好文 时间:
2014-07-31 16:14:27
阅读次数:
223
1 public ListNode detectCycle(ListNode head) { 2 ListNode s=head; 3 ListNode f=head; 4 while(f!=null&&f.next!=null){ 5 ...
分类:
其他好文 时间:
2014-07-31 16:01:36
阅读次数:
167
问题:判断链表是否有环。分析:利用快慢指针slow,fast slow指针每次走一步,fast指针每次走两步,倘若存在环,则slow和fast必定在某一时刻相遇。 由于fast指针走的比slow快所以循环的时候只需要判断fast和fast->next不为空,判断fast->next是因为...
分类:
其他好文 时间:
2014-07-31 12:25:26
阅读次数:
236