算法描述: Given a singly linked list L: L0→L1→…→Ln-1→Ln,reorder it to: L0→Ln→L1→Ln-1→L2→Ln-2→… You may not modify the values in the list's nodes, only nod ...
分类:
其他好文 时间:
2019-02-06 18:26:00
阅读次数:
185
算法描述: Given a linked list, return the node where the cycle begins. If there is no cycle, return null. To represent a cycle in the given linked list, w ...
分类:
其他好文 时间:
2019-02-06 17:14:52
阅读次数:
150
算法描述: 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 dee ...
分类:
其他好文 时间:
2019-02-06 14:30:29
阅读次数:
165
源地址:https://leetcode.com/problems/linked-list-cycle/ 判断链表是否有环路 首先最开始想到的办法是存储访问过的节点,之后看当前节点的next是否指向已经遍历过的节点,这样的时间复杂度是O(n),空间复杂度也是O(n)。使用ArrayList存储会非常 ...
分类:
其他好文 时间:
2019-02-05 22:17:21
阅读次数:
188
Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integer poswhich represents the posit ...
分类:
其他好文 时间:
2019-02-03 23:34:47
阅读次数:
201
算法描述: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balance ...
分类:
其他好文 时间:
2019-02-03 11:05:02
阅读次数:
142
算法描述: Given a binary tree, flatten it to a linked list in-place. For example, given the following tree: The flattened tree should look like: 解题思路:从题目可 ...
分类:
其他好文 时间:
2019-02-03 10:44:18
阅读次数:
181
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 ...
分类:
其他好文 时间:
2019-02-02 21:56:26
阅读次数:
180
Reverse a singly linked list. Example: Follow up: A linked list can be reversed either iteratively or recursively. Could you implement both? 解法一:遍历(我的 ...
分类:
其他好文 时间:
2019-02-02 20:36:53
阅读次数:
159
算法描述: Reverse a linked list from position m to n. Do it in one-pass. Note: 1 ≤ m ≤ n ≤ length of list. Example: 解题思路:链表题,首先要画图。四个指针,头指针,前指针,临时指针。 ...
分类:
其他好文 时间:
2019-02-02 14:17:43
阅读次数:
165