码迷,mamicode.com
首页 >  
搜索关键字:linked    ( 5490个结果
(java) Merge k sorted linked lists and return it as one sorted list. Analyze and describe its complexity.
1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ListNode next; 6 * ListNode(int x) { 7 * ...
分类:编程语言   时间:2014-07-16 17:45:41    阅读次数:226
两个有序链表连接(归并排序中用到的)
刚才写了k个,顺手写个2个的,在链表的归并排序中很有用,效率非常好 1 /** 2 * Definition for singly-linked list. 3 * public class ListNode { 4 * int val; 5 * ListNode next;...
分类:其他好文   时间:2014-07-16 17:42:41    阅读次数:275
LeetCode——Remove Duplicates from Sorted List II
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list. For example, Given 1->2->3->3->4->4->5, return 1->2->5. Given 1->1-...
分类:其他好文   时间:2014-07-16 17:30:52    阅读次数:230
UVA Getting in Line
题目如下: Getting in Line  Computer networking requires that the computers in the network be linked. This problem considers a ``linear" network in which the computers are chaine...
分类:其他好文   时间:2014-07-16 17:11:41    阅读次数:245
leetcode——Insertion Sort List 对链表进行插入排序(AC)
Sort a linked list using insertion sort. class Solution { public: ListNode *insertionSortList(ListNode *head) { if(head == NULL || head->next == NULL) return head; Lis...
分类:其他好文   时间:2014-07-15 12:22:53    阅读次数:244
待字闺中之快排(QuickSort)单向链表(Singly Linked List)
题目来源,待字闺中,原创@陈利人 ,欢迎大家继续关注微信公众账号“待字闺中” 分析:思路和数据的快速排序一样,都需要找到一个pivot元素、或者节点。然后将数组或者单向链表划分为两个部分,然后递归分别快排。 针对数组进行快排的时候,交换交换不同位置的数值,在分而治之完成之后,数据就是排序好的。那么单向链表是什么样的情况呢?除了交换节点值之外,是否有其他更好的方法呢?可以修改指针,不进行数值...
分类:其他好文   时间:2014-07-14 20:48:18    阅读次数:280
【leetcode刷题笔记】Sort List
Sort a linked list inO(nlogn) time using constant space complexity.题解:实现一个链表的归并排序即可。主要分为三部分:1.找到中点并返回的函数findMiddle;2.归并函数merge;3.排序函数sortList。数组的findM...
分类:其他好文   时间:2014-07-14 20:00:56    阅读次数:182
[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 the nodes' values.For ...
分类:其他好文   时间:2014-07-14 19:33:04    阅读次数:215
【leetcode刷题笔记】Insertion Sort List
Sort a linked list using insertion sort.题解:实现链表的插入排序。要注意的地方就是,处理链表插入的时候尽量往当前游标的后面插入,而不要往前面插入,后者非常麻烦。所以每次利用kepeler.next.val和head.val比较大小,而不是kepeler.val...
分类:其他好文   时间:2014-07-14 17:47:19    阅读次数:207
Add Two Numbers
You are given two linked lists representing two non-negative numbers. The digits are stored in reverse order and each of their nodes contain a single digit. Add the two numbers and return it as a link...
分类:其他好文   时间:2014-07-13 18:20:52    阅读次数:202
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!