码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
Merge k Sorted Lists -- leetcode
Merge k Sorted ListsMerge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.两种实现方法,第一种采用优先队列,第二种采用分治/** * Definition for singly-linked list. * struct ListNo...
分类:其他好文   时间:2014-11-27 20:36:39    阅读次数:227
leetcode-Remove Nth Node From End of List
Given a linked list, remove the nth node from the end of list and return its head. For example, Given linked list: 1->2->3->4->5, and n = 2. After removing the second node from the end, the l...
分类:其他好文   时间:2014-11-27 09:14:31    阅读次数:197
Leetcode-Sort List
Sort a linked list in O(n log n) time using constant space complexity.Analsys:We use Merge Sort.NOTE: We should practice other sort algorithm, linke Q...
分类:其他好文   时间:2014-11-27 01:35:39    阅读次数:213
LeetCode Merge Two Sorted Lists 归并排序
1 /** 2 * Definition for singly-linked list. 3 * struct ListNode { 4 * int val; 5 * ListNode *next; 6 * ListNode(int x) : val(x), ne...
分类:编程语言   时间:2014-11-26 23:59:34    阅读次数:350
Remove Duplicates from Sorted List II
Remove Duplicates from Sorted List IIGiven a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the or...
分类:其他好文   时间:2014-11-26 20:34:57    阅读次数:238
LeetCode[Linked List]: Linked List Cycle
Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra space? 这个题目如果没有空间复杂度O(1)的限制,我可以想到的方法就是:遍历整个list,将每个节点的地址存入一个vector,如果发现某个节点的next的地址已经在vec...
分类:其他好文   时间:2014-11-26 19:02:15    阅读次数:119
Remove Duplicates from Sorted List
Given a sorted linked list, delete all duplicates such that each element appear only once. For example, Given 1->1->2, return 1->2. Given 1->1->2->3->3, return 1->2->3. #include #include ...
分类:其他好文   时间:2014-11-26 18:59:03    阅读次数:155
LeetCode[Linked List]: Linked List Cycle II
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Follow up: Can you solve it without using extra space? 这个题目跟Linked List Cycle一样,我也没有能够自己独立找到解决方法,...
分类:其他好文   时间:2014-11-26 18:57:10    阅读次数:126
【原创】leetCodeOj ---Partition List 解题报告
原题地址:https://oj.leetcode.com/problems/partition-list/题目内容:Given a linked list and a valuex, partition it such that all nodes less thanxcome before nod...
分类:其他好文   时间:2014-11-26 18:47:01    阅读次数:196
对链表排序,时间开销O(nlogn), 空间开销O(1)
Sort a linked list in O(n log n) time using constant space complexity....
分类:编程语言   时间:2014-11-26 16:37:32    阅读次数:172
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!