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- ...
分类:
其他好文 时间:
2019-04-09 17:04:04
阅读次数:
152
Given a linked list, return the node where the cycle begins. If there is no cycle, return null. Note: Do not modify the linked list. Follow up:Can you ...
分类:
其他好文 时间:
2019-04-09 16:55:57
阅读次数:
173
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 ...
分类:
其他好文 时间:
2019-04-09 16:52:33
阅读次数:
130
Sort a linked list using insertion sort. public class Solution { public ListNode insertionSortList(ListNode head) { ListNode root = new ListNode(0); / ...
分类:
其他好文 时间:
2019-04-09 16:52:19
阅读次数:
118
Given a linked list, swap every two adjacent nodes and return its head. For example,Given 1->2->3->4, you should return the list as 2->1->4->3. Your a ...
分类:
其他好文 时间:
2019-04-09 16:44:26
阅读次数:
112
Given a linked list, remove the nth node from the end of list and return its head. For example, Note:Given n will always be valid.Try to do this in on ...
分类:
其他好文 时间:
2019-04-09 16:38:07
阅读次数:
151
Sort a linked list in O(n log n) time using constant space complexity. //利用归并排序的思想 class Solution { public ListNode sortList(ListNode head) { if (head ...
分类:
其他好文 时间:
2019-04-09 16:34:21
阅读次数:
152
* Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * ListNode(int x) { val = x; } * } ...
分类:
其他好文 时间:
2019-04-09 16:29:28
阅读次数:
146
```
/**
* Definition for singly-linked list.
* struct ListNode {
* int val;
* ListNode *next;
* ListNode(int x) : val(x), next(NULL) {}
* };
*/
class ... ...
分类:
其他好文 时间:
2019-04-09 12:32:43
阅读次数:
152
Sort a linked list in O(n log n) time using constant space complexity. 这道题目非常简短的一句话。给链表排序,看到nlogn。我们能够来简单复习一下排序。首先说一下这个nlogn的时间复杂度(依据决策树我们能够得出这个界限)。是基 ...
分类:
其他好文 时间:
2019-04-07 16:57:10
阅读次数:
126