码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
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 e...
分类:其他好文   时间:2014-08-11 14:44:32    阅读次数:186
【leetcode】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) Outpu...
分类:其他好文   时间:2014-08-10 13:08:30    阅读次数:296
Linked List Cycle && Linked List Cycle II
说明:两个指针不同步长。 说明:在上题基础上,将一个指针放到链表头,步长都设为1,相遇节点。(可以计算)
分类:其他好文   时间:2014-08-10 03:53:49    阅读次数:222
Insertion Sort List
Sort a linked list using insertion sort.思路:若当前元素比head小,插入已排序队列头部;否则,从前往后查找当前元素的插入位置。 1 ListNode *insertionSortList( ListNode *head ) { 2 if( !head...
分类:其他好文   时间:2014-08-10 01:30:39    阅读次数:313
Sort List
Sort a linked list in O(n log n) time using constant space complexity.思路:题目要求O(n log n)的时间复杂度以及常空间复杂度,因此,使用归并排序策略。 1 class Solution { 2 public: 3 ...
分类:其他好文   时间:2014-08-09 23:13:19    阅读次数:284
判断链表是否有环及环入口点的求法(Linked List Cycle II )
分为两步 第一步 还是利用快慢指针,如果有环的话在利用快慢指针终会相会于一个节点。 第二步。然后从这节点出发每次出发走一步,同时从根节点出发每次出发也走一步则他们两个指针相遇的地方就是环的入口。 第一步好解释那么第二步是为什么呢? 网上有很多解法大都是从数学的角度来分析,有公式也有推算很不直观,我从图形的角度来看的话就相对理解起来简单很多。 将图摊开成一条线,假设我们有环而且...
分类:其他好文   时间:2014-08-09 02:40:07    阅读次数:309
amazon 面经3
http://www.geeksforgeeks.org/amazon-interview-set-107/F2F-I:1) Brief discussion on work in current company2) Flatten linked list – http://www.geeksfor...
分类:其他好文   时间:2014-08-08 06:22:45    阅读次数:375
【LeetCode】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 of the list. 思路:第一遍正常复制链表,同时用哈希表保存链表中原始节点和新...
分类:其他好文   时间:2014-08-07 23:22:45    阅读次数:280
【LeetCode】Reverse Linked List II
Reverse a linked list from position m to n. Do it in-place and in one-pass. For example: Given 1->2->3->4->5->NULL, m = 2 and n = 4, return 1->4->3->2->5->NULL. Note: Given m, n satisfy t...
分类:其他好文   时间:2014-08-07 19:02:50    阅读次数:251
[LeetCode 题解]: Reverse Nodes in K-Groups
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-08-07 00:37:17    阅读次数:187
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!