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 the original relative order of...
分类:
其他好文 时间:
2014-08-21 19:23:34
阅读次数:
295
1 package com.lw.leet5; 2 3 /** 4 * @ClassName:Solution 5 * @Description: 6 * Insertion Sort List 7 * Sort a linked list using ...
分类:
其他好文 时间:
2014-08-20 22:36:32
阅读次数:
187
Sort a linked list using insertion sort.1st ( 3 tries)/** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next...
分类:
其他好文 时间:
2014-08-20 14:03:52
阅读次数:
172
Sort a linked list inO(nlogn) time using constant space complexity.1st ( 7 tries)/** * Definition for singly-linked list. * struct ListNode { * in...
分类:
其他好文 时间:
2014-08-20 14:03:02
阅读次数:
198
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...
分类:
其他好文 时间:
2014-08-19 22:08:15
阅读次数:
238
package com.lw.leet4;/** * @ClassName:Solution * @Description: * Sort List * Sort a linked list in O(n log n) time using constant spa...
分类:
其他好文 时间:
2014-08-18 20:26:22
阅读次数:
170
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
* Sort a linked list in O(n log n) time using const...
分类:
其他好文 时间:
2014-08-18 14:31:02
阅读次数:
191
Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST.思路:使用两个指针分别以1、2的速度遍历链表,以定位出链表的中点,进而将链表分割成...
分类:
其他好文 时间:
2014-08-17 02:21:36
阅读次数:
246
Given a binary tree, flatten it to a linked list in-place.For example,Given 1 / \ 2 5 / \ \ 3 4 6The flattened t...
分类:
其他好文 时间:
2014-08-16 22:23:31
阅读次数:
269
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-16 16:21:10
阅读次数:
229