↓Skip to main content

Linked-List

LeetCode 328: Odd Even Linked List
·2 mins
LeetCode Medium Linked-List
LeetCode 328 note: build one list from odd positions and one from even positions, then append the even list to the odd one; remember to cut the even list’s tail
LeetCode 25: Reverse Nodes in k-Group
·2 mins
LeetCode Hard Linked-List Recursion
LeetCode 25 note: count the length to know how many full groups to reverse, k nodes each; a dummy head avoids special-casing the first group, and the old group head becomes its tail
LeetCode 460: LFU Cache
·3 mins
LeetCode Hard Hash-Table Linked-List Design Doubly-Linked-List
LeetCode 460 note: key → node, freq → doubly linked list, plus a min_freq; within the same frequency, LRU decides what to evict
LeetCode 146: LRU Cache
·3 mins
LeetCode Medium Hash-Table Linked-List Design Doubly-Linked-List
LeetCode 146 note: a hash map finds nodes and a doubly linked list keeps the usage order; both get and updating an existing key must move the node to the front
Linked List
·6 mins
Algorithm Linked-List Two-Pointers
Dummy heads, reversal (whole list, a range, half), fast and slow pointers for middles and cycles, two pointers n apart, pairwise swaps, two lists meeting, and copying a list with random pointers via a hash map
LeetCode 23: Merge k Sorted Lists
·4 mins
LeetCode Hard Linked-List Heap Merge-Sort Divide-and-Conquer
LeetCode 23 note: a heap that holds only k heads, and divide-and-conquer pairwise merging
LeetCode 21: Merge Two Sorted Lists
·3 mins
LeetCode Easy Linked-List Two-Pointers Merge-Sort
LeetCode 21 note: the dummy node, and why Python assignment is not a copy
LeetCode 1290: Convert Binary Number in a Linked List to Integer
·2 mins
LeetCode Easy Linked-List Bit-Manipulation Math
LeetCode 1290 note: walk head to tail, shifting the running value left by one and adding the new bit
LeetCode 2487: Remove Nodes From Linked List
·1 min
LeetCode Medium Linked-List Stack Recursion Monotonic-Stack
LeetCode 2487 note: the kept nodes are non-increasing left to right; keep a monotonic stack, pop anything smaller than the new node, then link what remains
LeetCode 92: Reverse Linked List II
·2 mins
LeetCode Medium Linked-List
LeetCode 92 note: walk a dummy to the node before left, then move the following nodes one at a time to just after it, right - left times
LeetCode 109: Convert Sorted List to Binary Search Tree
·2 mins
LeetCode Medium Linked-List Divide-and-Conquer Tree Binary-Search-Tree
LeetCode 109 note: take the middle found with fast and slow pointers as the root and recurse on both halves; the height balances naturally
LeetCode 117: Populating Next Right Pointers in Each Node II
·2 mins
LeetCode Medium Linked-List Tree Depth-First-Search Breadth-First-Search Binary-Tree
LeetCode 117 note: connect next pointers level by level with BFS; for a non-perfect tree, looking only at the neighbour’s children breaks the chain