This article summarizes the questions about linked lists in HOT100, analyzes ideas and writes the code. The questions are shown in the figure below (a total of 9 questions, 5 simple + 4 medium, difficult questions are omitted)
simple
(1) Question 21: Combine two ordered linked lists
Merge two ordered linked lists (recursion + iteration)
(2) Question 141: Circular Linked List
Likou 141 circular linked watch (hash watch + speed pointer)
(3) Question 160 Intersect Linked List
Likou 160 intersecting linked list (double pointer + hash table)
(4) Question 206: Reverse linked list
Likou 206 reverse linked list (iteration + recursion)
(5) Question 234: Palindrome linked list
Likou 234 palindrome linked list (array, fast and slow pointer, stack, etc.)
medium
(6) Question 2 Add two numbers
Force button 2 to add two numbers (define pre-pointer)
(7) Question 19 Delete the Nth node from the bottom of the linked list
Leikou 19 Delete the Nth node from the bottom of the linked list (define a dummy node)
(8) Question 142: Circular Linked List II
Likou 142 Ring Linked Watch II (hash watch, fast and slow pointer (omitted))
(9) Question 148: Sort Linked List
This question will not be summarized for the time being, and it will be added after reading the merger and sorting.
Likou 148 sorted linked list