码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
LeetCode OJ - Sort List
题目: Sort a linked list inO(nlogn) time using constant space complexity.解题思路: 复杂度为O(n* logn) 的排序算法有:快速排序、堆排序、归并排序。对于链表这种数据结构,使用归并排序比较靠谱。递归代码如下:代码: /...
分类:其他好文   时间:2014-05-16 05:49:04    阅读次数:266
LeetCode OJ - Insertion Sort List
题目: Sort a linked list using insertion sort.解题思路: 假设 list[1..i]是排好序的,找到第i+1个元素应该插入的位置及其前驱,然后将其插入。代码: /** * Definition for singly-linked list. * str...
分类:其他好文   时间:2014-05-16 05:47:08    阅读次数:258
LeetCode OJ - 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?解题思路: 使用快慢指针,快指针每次走两步,慢指针每次走一步...
分类:其他好文   时间:2014-05-16 05:19:21    阅读次数:271
LeetCode OJ - Linked List Cycle II
题目: 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 extr...
分类:其他好文   时间:2014-05-16 04:50:13    阅读次数:329
Copy List with Random Pointer
A linked list is given such that each node contains an additional random pointer which could point to any node in the list or null.Return a deep copy ...
分类:其他好文   时间:2014-05-15 21:00:06    阅读次数:325
Leetcode 线性表 Linked List Cycle
题意:判断一个链表中是否有环 思路:快慢指针,如果有环,最终快慢指针会在非NULL相遇 注:用到fast->next前先要确保fast非NULL,要用fast->next->next前先要确保fast,fast->next非NULL 复杂度:时间O(n), 空间O(1) 相关题目:Linked List CycleII...
分类:其他好文   时间:2014-05-15 07:01:57    阅读次数:219
LeetCode-004 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 linked list. Input: (2 -> 4 -> 3) + (5 -> 6 -> 4) Out...
分类:其他好文   时间:2014-05-15 05:13:49    阅读次数:306
LeetCode--Linked List Cycle
Linked List Cycle  Total Accepted: 17148 Total Submissions: 49300My Submissions Given a linked list, determine if it has a cycle in it. Follow up: Can you solve it without using extra sp...
分类:其他好文   时间:2014-05-15 00:13:50    阅读次数:279
【LeetCode】Linked List Cycle
Linked List CycleGiven a linked list, determine if it has a cycle in it.Follow up:Can you solve it without using extra space?做完Linked List Cycle II在做这...
分类:其他好文   时间:2014-05-14 23:30:00    阅读次数:399
LeetCode Sort List
在 O(nlogn)的时间内对一个链表进行排序。。明显是要用归并或者快排 第一次知道说原来归并也可以用链表来写,被刷了下三观。。。。。用快慢指针的方法找分界点。 /** * Definition for singly-linked list. * struct ListNode { * int val; * ListNode *next; * ListNod...
分类:其他好文   时间:2014-05-14 15:03:49    阅读次数:230
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!