上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 16 下一页

Leetcode: Merge k Sorted Lists

摘要: Mergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.分析:一个很简单的解法是调用k-1次merge two sorted linkedlist,假设每个list... 阅读全文
posted @ 2014-11-24 22:19 Ryan-Xing 阅读(184) 评论(0) 推荐(0) 编辑

Leetcode: Merge Two Sorted Lists

摘要: Merge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.代码:class ... 阅读全文
posted @ 2014-11-19 20:02 Ryan-Xing 阅读(121) 评论(0) 推荐(0) 编辑

Leetcode: Partition List

摘要: 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... 阅读全文
posted @ 2014-11-19 19:52 Ryan-Xing 阅读(115) 评论(0) 推荐(0) 编辑

Leetcode: Remove Duplicates from Sorted List II

摘要: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list.For example,Given1->2->3-... 阅读全文
posted @ 2014-11-17 22:40 Ryan-Xing 阅读(158) 评论(0) 推荐(0) 编辑

Leetcode: Remove Nth Node From End of List

摘要: 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... 阅读全文
posted @ 2014-11-17 22:07 Ryan-Xing 阅读(132) 评论(0) 推荐(0) 编辑

Leetcode: Reorder List

摘要: Given a singly linked listL: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 exam... 阅读全文
posted @ 2014-11-17 21:38 Ryan-Xing 阅读(162) 评论(0) 推荐(0) 编辑

Leetcode: Reverse Linked List II

摘要: 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... 阅读全文
posted @ 2014-11-17 13:28 Ryan-Xing 阅读(189) 评论(0) 推荐(0) 编辑

Leetcode: Reverse Nodes in k-Group

摘要: 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... 阅读全文
posted @ 2014-11-17 12:26 Ryan-Xing 阅读(175) 评论(0) 推荐(0) 编辑

Rotate List

摘要: Given a list, rotate the list to the right bykplaces, wherekis non-negative.For example:Given1->2->3->4->5->NULLandk=2,return4->5->1->2->3->NULL.分析:此题... 阅读全文
posted @ 2014-11-16 15:59 Ryan-Xing 阅读(196) 评论(0) 推荐(0) 编辑

Sort List

摘要: Sort a linked list inO(nlogn) time using constant space complexity.分析:merge sort。class Solution {public: ListNode *sortList(ListNode *head) { ... 阅读全文
posted @ 2014-11-16 15:23 Ryan-Xing 阅读(197) 评论(0) 推荐(0) 编辑
上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 16 下一页