![](https://img-blog.csdnimg.cn/20201014180756919.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
Linked List
林下溪源
为学日益,为道日损
展开
-
237. Delete Node in a Linked List
Problem: Write 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: Exampl...原创 2020-03-26 11:42:07 · 128 阅读 · 0 评论 -
234. Palindrome Linked List
Problem: Given a singly linked list, determine if it is a palindrome. Example 1: Input: 1->2 Output: false Example 2: Input: 1->2->2->1 Output: true Follow up: Could you do it in ...原创 2020-03-24 12:26:14 · 94 阅读 · 0 评论 -
206. Reverse Linked List
Problem: Reverse a singly linked list. Example: Input: 1->2->3->4->5->NULL Output: 5->4->3->2->1->NULL Follow up: A linked list can be reversed either iteratively...原创 2020-03-24 12:20:29 · 132 阅读 · 0 评论 -
203. Remove Linked List Elements
Problem: Remove all elements from a linked list of integers that have valueval. Example: Input: 1->2->6->3->4->5->6, val = 6 Output: 1->2->3->4->5 Analysis: 本题的...原创 2020-03-24 12:08:04 · 117 阅读 · 0 评论 -
160. Intersection of Two Linked Lists
Problem: Write a program to find the node at which the intersection of two singly linked lists begins. For example, the following two linked lists: begin to intersect at node c1. Example 1: ...原创 2020-03-24 11:51:07 · 107 阅读 · 0 评论 -
148. Sort List
Problem: Sort a linked list inO(nlogn) time using constant space complexity. Example 1: Input: 4->2->1->3 Output: 1->2->3->4 Example 2: Input: -1->5->3->4->0 ...原创 2020-03-23 18:08:21 · 107 阅读 · 0 评论 -
143. Reorder List
Problem: Given 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: Giv...原创 2020-03-20 16:29:48 · 86 阅读 · 0 评论 -
142. Linked List Cycle II
Problem: Given 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 po...原创 2020-03-20 15:34:38 · 83 阅读 · 0 评论 -
141. Linked List Cycle
Problem: Given a linked list, determine if it has a cycle in it. To represent a cycle in the given linked list, we use an integerposwhich represents the position (0-indexed)in the linked list wh...原创 2020-03-20 15:12:42 · 115 阅读 · 0 评论 -
109. Convert Sorted List to Binary Search Tree
Problem: Given a singly linked list where elements are sorted in ascending order, convert it to a height balanced BST. For this problem, a height-balanced binary tree is defined as a binary tree in...原创 2020-03-20 14:58:00 · 125 阅读 · 0 评论 -
92. Reverse Linked List II
Problem: Reverse 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 = 4 Output: 1->4->3-&...原创 2020-03-19 17:39:29 · 93 阅读 · 0 评论 -
86. Partition List
Problem: Given 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 i...原创 2020-03-19 16:27:21 · 126 阅读 · 0 评论 -
83. Remove Duplicates from Sorted List
Problem: Given a sorted linked list, delete all duplicates such that each element appear onlyonce. Example 1: Input: 1->1->2 Output: 1->2 Example 2: Input: 1->1->2->3->3...原创 2020-03-19 15:29:13 · 77 阅读 · 0 评论 -
82. Remove Duplicates from Sorted List II
Problem: Given a sorted linked list, delete all nodes that have duplicate numbers, leaving onlydistinctnumbers from the original list. Return the linked list sorted as well. Example 1: Input: ...原创 2020-03-19 13:43:26 · 114 阅读 · 0 评论 -
61. Rotate List
Problem: Given a linkedlist, rotate the list to the right bykplaces, wherekis non-negative. Example 1: Input: 1->2->3->4->5->NULL, k = 2 Output: 4->5->1->2->3->...原创 2020-03-19 12:24:08 · 96 阅读 · 0 评论