LeeCode_Linked Lists
Haskei
这个作者很懒,什么都没留下…
展开
-
[Leetcode] 426. Convert Binary Search Tree to Sorted Doubly Linked List
426.Convert Binary Search Tree to Sorted Doubly Linked List (题目链接)MediumConvert aBinary Search Treeto a sortedCircular Doubly-Linked Listin place.You can think of the left and right pointers as synonymous to the predecessor and successor pointer...原创 2020-08-06 07:14:25 · 156 阅读 · 0 评论 -
[Leetcode] 237. Delete Node in a Linked List 给出链表中的某个节点,删除该节点
237.Delete Node in a Linked List (题目链接)EasyWrite a function to delete a node (except the tail) in a singly linked list, given only access to that node.Given linked list --head =[4,5,1,9], which looks like following:Example 1:Input: head ...原创 2020-08-18 12:19:09 · 142 阅读 · 0 评论 -
[Leetcode] 148. Sort List (归并排序链表) 快慢指针
148.Sort List (题目链接)MediumSort a linked list inO(nlogn) time using constant space complexity.Example 1:Input: 4->2->1->3Output: 1->2->3->4Example 2:Input: -1->5->3->4->0Output: -1->0->3->4->5...原创 2020-08-17 10:58:44 · 154 阅读 · 0 评论 -
[Leetcode] 142. Linked List Cycle II (set / 快慢指针)
142.Linked List Cycle II (题目链接)MediumGiven a linked list, return the node where the cycle begins. If there is no cycle, returnnull.To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the...原创 2020-08-17 08:36:08 · 158 阅读 · 0 评论 -
[Leetcode] 143. Reorder List 重新排列链表
143.Reorder List (题目链接)MediumGiven a singly linked listL:L0→L1→…→Ln-1→Ln,reorder it to:L0→Ln→L1→Ln-1→L2→Ln-2→…You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example 1:Given 1->2->3->4, reorder i...原创 2020-08-16 05:10:45 · 157 阅读 · 0 评论 -
2020-08-15
24.Swap Nodes in Pairs (题目链接)MediumGiven alinked list, swap every two adjacent nodes and return its head.You maynotmodify the values in the list's nodes, only nodes itself may be changed.Example:Given 1->2->3->4, you should retur...原创 2020-08-16 03:52:20 · 174 阅读 · 0 评论 -
[Leetcode] 86. Partition List 链表分组
86.Partition List (题目链接)MediumGiven a linked list and a valuex, partition it such that all nodes less thanxcome before nodes greater than or equal tox.You should preserve the original relative order of the nodes in each of the two partitions.E...原创 2020-08-15 14:11:38 · 175 阅读 · 0 评论 -
[Leetcode] 92. Reverse Linked List II 指定翻转m~n的链表
92.Reverse Linked List II (题目链接)MediumReverse a linked list from positionmton. Do it in one-pass.Note:1 ≤m≤n≤ length of list.Example:Input: 1->2->3->4->5->NULL, m = 2, n = 4Output: 1->4->3->2->5->NULL思路:...原创 2020-08-15 13:14:01 · 148 阅读 · 0 评论 -
23. Merge k Sorted Lists (Python)暴力+分治+最小堆
23.Merge k Sorted ListsHardMergeksorted linked lists and return it as one sorted list. Analyze and describe its complexity.Example:Input:[ 1->4->5, 1->3->4, 2->6]Output: 1->1->2->3->4->4->5->6笔记...原创 2020-05-30 07:09:26 · 297 阅读 · 0 评论 -
206. Reverse Linked List (Python)
206.Reverse Linked ListEasyReverse a singly linked list.Example:Input: 1->2->3->4->5->NULLOutput: 5->4->3->2->1->NULLFollow up:A linked list can be reversed either iteratively or recursively. Could you implemen.原创 2020-05-29 06:24:42 · 276 阅读 · 0 评论 -
138. Copy List with Random Pointer (Python)
138.Copy List with Random PointerMediumA 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 adeep copyof the list.The Linked List is represented in the input/ou...原创 2020-05-29 06:02:05 · 279 阅读 · 0 评论 -
25. Reverse Nodes in k-Group (Python)
25.Reverse Nodes in k-GroupHardGiven a linked list, reverse the nodes of a linked listkat a time and return its modified list.kis a positive integer and is less than or equal to the length of the linked list. If the number of nodes is not a multi...原创 2020-05-28 13:06:26 · 221 阅读 · 0 评论 -
21. Merge Two Sorted Lists (Python)
21.Merge Two Sorted ListsEasyMerge two sorted linked lists and return it as a new list. The new list should be made by splicing together the nodes of the first two lists.Example:Input: 1->2->4, 1->3->4Output: 1->1->2->3->.原创 2020-05-28 04:46:50 · 324 阅读 · 0 评论 -
2. Add Two Numbers (Python)
2.Add Two NumbersMediumYou are given twonon-emptylinked lists representing two non-negative integers. The digits are stored inreverse orderand each of their nodes contain a single digit. Add the two numbers and return it as a linked list.You may...原创 2020-05-28 01:19:19 · 251 阅读 · 0 评论