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 multiple ofkthen left-o...
分类:
其他好文 时间:
2014-11-17 13:56:54
阅读次数:
182
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 example,
Given {1,2,3,4}, reorder itto {1,4,...
分类:
其他好文 时间:
2014-11-17 10:45:06
阅读次数:
179
Sort a linked list using insertion sort.Solution: 1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ...
分类:
其他好文 时间:
2014-11-17 09:11:05
阅读次数:
218
Jeff Lee blog: http://www.cnblogs.com/Alandre/ (泥沙砖瓦浆木匠),retain the url when reproduced ! Thanks Linked list is a normal data structure.here I show ho...
分类:
编程语言 时间:
2014-11-17 09:10:51
阅读次数:
169
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-16 17:10:02
阅读次数:
276
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-16 15:57:02
阅读次数:
131
Sort a linked list inO(nlogn) time using constant space complexity.分析:merge sort。class Solution {public: ListNode *sortList(ListNode *head) { ...
分类:
其他好文 时间:
2014-11-16 15:51:43
阅读次数:
210
Skip List | Set 1 (Introduction)Can we search in a sorted linked list in better than O(n) time?The worst case search time for a sorted linked list is ...
分类:
其他好文 时间:
2014-11-16 15:49:53
阅读次数:
173
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-16 14:38:00
阅读次数:
175
Reverse a linked list from positionmton. Do it in-place and in one-pass.For example:Given1->2->3->4->5->NULL,m= 2 andn= 4,return1->4->3->2->5->NULL.No...
分类:
其他好文 时间:
2014-11-16 13:19:38
阅读次数:
160