Linked list algorithms.
Learn the idea, follow the pointers, then put it into code.
Basics
| Problem | Difficulty | Time complexity | Practice |
|---|---|---|---|
| Traversal & Search | Easy | O(n) | GFG |
| Insert & Delete by Position | Easy | O(n) | LeetCode |
| Remove Duplicates from a Sorted List | Easy | O(n) | LeetCode |
Fast & slow pointers
| Problem | Difficulty | Time complexity | Practice |
|---|---|---|---|
| Middle of a Linked List | Easy | O(n) | LeetCode |
| Detect a Linked List Cycle | Easy | O(n) | LeetCode |
| Find the Cycle Entry | Medium | O(n) | LeetCode |
| Remove the Nth Node from the End | Medium | O(n) | LeetCode |
| Intersection of Two Linked Lists | Easy | O(n + m) | LeetCode |
Reversal
| Problem | Difficulty | Time complexity | Practice |
|---|---|---|---|
| Reverse a Linked List | Easy | O(n) | LeetCode |
| Palindrome Linked List | Easy | O(n) | LeetCode |
| Reorder a Linked List | Medium | O(n) | LeetCode |
| Rotate a Linked List | Medium | O(n) | LeetCode |
| Reverse Nodes in k-Group | Hard | O(n) | LeetCode |
Merging & sorting
| Problem | Difficulty | Time complexity | Practice |
|---|---|---|---|
| Merge Two Sorted Lists | Easy | O(n + m) | LeetCode |
| Merge k Sorted Lists | Hard | O(N log(k + 1) + k) | LeetCode |
| Merge Sort on a Linked List | Medium | O(n log n) | LeetCode |
Construction
| Problem | Difficulty | Time complexity | Practice |
|---|---|---|---|
| Add Two Numbers | Medium | O(max(n, m)) | LeetCode |
| Copy a List with Random Pointers | Medium | O(n) expected | LeetCode |