- LeetCode
- 234. Palindrome Linked List
- 2. Add Two Numbers
- 371. Sum of Two Integers
- 160. Intersection of Two Linked Lists
- 599. Minimum Index Sum of Two Lists
- 202. Happy Number
- 141. Linked List Cycle
- 142. Linked List Cycle II
- 206. Reverse Linked List
- 92. Reverse Linked List II
- 143. Reorder List
- 19. Remove Nth Node From End of List
- 1721. Swapping Nodes in a Linked List
- 24. Swap Nodes in Pairs
- 25. Reverse Nodes in k-Group
- 21. Merge Two Sorted Lists
- 23. Merge k Sorted Lists
- 82. Remove Duplicates from Sorted List II
# LeetCode
# 234. Palindrome Linked List
If the head pointer is nil, return true.
Solution 1
We could push values into an array and use two pointer sliding from start and end respectively.
Time complexity O(n), space complexity O(n)
1 | |
Solution 2
Reverse the first half of list and compare them.
1 | |
# 2. Add Two Numbers
1 | |
Simplified Version
1 | |
# 371. Sum of Two Integers
Bit operation, the basic theory of full adder.
1 | |
# 160. Intersection of Two Linked Lists
Brute Force
Hash Table
Traverse through list a and get d. Traverse through b to check if b is in d.
Concat Two Lists
1 | |
# 599. Minimum Index Sum of Two Lists
Brute Force
Hash Table
1 | |
# 202. Happy Number
Floyd Cycle Detection Using Two Pointers.
1 | |
# 141. Linked List Cycle
Two pointers to detect cycle.
1 | |
# 142. Linked List Cycle II
Two pointers
1 | |
# 206. Reverse Linked List
Two pointer
1 | |
1 | |
# 92. Reverse Linked List II
Need to think a little bit.
1 | |
1 | |
# 143. Reorder List
Combination of Reserve List I&II
1 | |
# 19. Remove Nth Node From End of List
1 | |
# 1721. Swapping Nodes in a Linked List
1 | |
# 24. Swap Nodes in Pairs
1 | |
# 25. Reverse Nodes in k-Group
1 | |
# 21. Merge Two Sorted Lists
1 | |
# 23. Merge k Sorted Lists
Use merge two lists
1 | |
# 82. Remove Duplicates from Sorted List II
1 | |