码迷,mamicode.com
首页 >  
搜索关键字:linked_list    ( 3784个结果
LeetCode 141, 142. Linked List Cycle I+II
判断链表有没有环,用Floyd Cycle Detection算法,用两个快慢指针。 判断环的起点,详见 https://leetcode.com/problems/linked-list-cycle-ii/solution/ 中的推导,不过里面应该是 F=(n-1)(a+b)+b,不过对结果没什么 ...
分类:其他好文   时间:2018-06-02 19:03:30    阅读次数:159
leetcode61. Rotated List
问题描述: Given a linked list, rotate the list to the right by k places, where k is non-negative. Example 1: Example 2: 解题思路: 这道题的rotate的定义很有趣,是把最后一个元素挪到了 ...
分类:其他好文   时间:2018-06-01 10:56:56    阅读次数:172
Linked List Cycle II & Reverse Words in a String & Fraction to Recurring Decimal
1. Linked List Cycle II Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked ...
分类:其他好文   时间:2018-05-25 11:08:15    阅读次数:167
237. Delete Node in a Linked List
在只能访问待删除节点的情况下删除一个链表的节点,直接把待删除节点的下一个节点值放在待删除节点,然后修改指针,跳过下一个节点即可。 ...
分类:其他好文   时间:2018-05-24 18:12:19    阅读次数:121
234. Palindrome Linked List
判定链表是否为回文 方法一:借助一个栈,将链表节点值全部压入栈中,再弹出,依次比较。本质是把链表节点值逆置,然后与原链表节点值比较。全部相等则为回文。 方法二:先计算链表长度,把前半部分链表逆置,然后比较新链和剩下那段链节点值是否依次相等。 ...
分类:其他好文   时间:2018-05-24 16:36:51    阅读次数:138
203. Remove Linked List Elements
新建一个头结点,方便算法实现。和数组删除给定值类似,不删除节点,不改变指针,而是覆盖节点值。通过覆盖节点值来达到压缩链表,实现删除给定值。 一个前指针指向覆盖节点前驱,一个后指针扫描链表。扫到非指定值,则将其赋给前指针的后继,扫到指定值,则仅仅移动后指针,继续扫描直到扫描完整个链表。 扫完之后,将前 ...
分类:其他好文   时间:2018-05-22 20:39:24    阅读次数:137
96. Partition List [easy]
Description Given a linked list and a value x, partition it such that all nodes less than x come before nodes greater than or equal to x. You should p ...
分类:其他好文   时间:2018-05-21 21:16:48    阅读次数:164
排序链表
中英题面 在 O(n log n) 时间复杂度和常数级空间复杂度下,对链表进行排序。 Sort a linked list in O(n log n) time using constant space complexity. 示例 1: 输入: 4->2->1->3 输出: 1->2->3->4 ...
分类:编程语言   时间:2018-05-20 10:40:58    阅读次数:226
1.3.30
question: write a function that takes the first node in a linked list as argument and (destructively) reverses the list, returning the first node in t ...
分类:其他好文   时间:2018-05-19 18:36:32    阅读次数:169
1.3.29
question: write a queue implementation that uses a cicular linked list, which is the same as a linked list except that no links are nul and the value ...
分类:其他好文   时间:2018-05-19 17:13:29    阅读次数:164
3784条   上一页 1 ... 68 69 70 71 72 ... 379 下一页
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!