
链表
Frontier_Setter
这个作者很懒,什么都没留下…
展开
-
[LeetCode] (medium) 138. Copy List with Random Pointer
https://leetcode.com/problems/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. Retu...原创 2019-02-15 18:07:56 · 221 阅读 · 2 评论 -
[LeetCode] (medium) 148. Sort List
https://leetcode.com/problems/sort-list/ Sort a linked list in O(n log n) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: In...原创 2019-02-15 22:40:31 · 98 阅读 · 0 评论 -
[LeetCode] (medium) 287. Find the Duplicate Number
https://leetcode.com/problems/find-the-duplicate-number/ Given an array nums containing n + 1 integers where each integer is between 1 and n (inclusive), prove that at least one duplicate number mus...转载 2019-02-18 13:40:42 · 175 阅读 · 0 评论 -
[LeetCode] (medium) 328. Odd Even Linked List
https://leetcode.com/problems/odd-even-linked-list/ Given a singly linked list, group all odd nodes together followed by the even nodes. Please note here we are talking about the node number and no...原创 2019-02-18 16:45:23 · 120 阅读 · 0 评论 -
[LeetCode] (medium) 24. Swap Nodes in Pairs
https://leetcode.com/problems/swap-nodes-in-pairs/ Given a linked list, swap every two adjacent nodes and return its head. You may not modify the values in the list's nodes, only nodes itself may b...原创 2019-02-25 11:04:50 · 117 阅读 · 0 评论 -
[小技巧] 链表的对半划分
使用快慢指针,fast每走两步,slow走一步,当fast停下时,slow就应该停止在链表的中间。 情况一: 当链表有头结点head时, fast = head; slow = head; while(fast != NULL && fast->next != NULL){ fast = fast->next->next; slow = ...原创 2019-03-01 21:38:50 · 272 阅读 · 0 评论