Hash-Table
LeetCode 763: Partition Labels
·2 mins
LeetCode
Medium
Hash-Table
Two-Pointers
String
Greedy
LeetCode 763 note: record each letter’s last index, extend the current part’s end while scanning, and cut when the scan reaches it
LeetCode 2385: Amount of Time for Binary Tree to Be Infected
·2 mins
LeetCode
Medium
Hash-Table
Tree
Depth-First-Search
Breadth-First-Search
Binary-Tree
LeetCode 2385 note: turn the tree into an undirected graph and BFS from start; the number of levels minus one is the answer
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
LeetCode 889: Construct Binary Tree from Preorder and Postorder Traversal
·2 mins
LeetCode
Medium
Array
Hash-Table
Divide-and-Conquer
Tree
Binary-Tree
LeetCode 889 note: keep the current path on a stack; when its top equals the next postorder value that subtree is complete and is popped; new nodes go left first
LeetCode 863: All Nodes Distance K in Binary Tree
·2 mins
LeetCode
Medium
Hash-Table
Tree
Depth-First-Search
Breadth-First-Search
Binary-Tree
LeetCode 863 note: turn the tree into an undirected graph (adding edges to parents), then BFS k steps from target
LeetCode 652: Find Duplicate Subtrees
·2 mins
LeetCode
Medium
Hash-Table
Tree
Depth-First-Search
Binary-Tree
LeetCode 652 note: encode every subtree in post-order and report it on its second occurrence; string keys are O(n^2) worst case, (val, left id, right id) ids make it O(n)
LeetCode 314: Binary Tree Vertical Order Traversal
·2 mins
LeetCode
Medium
Hash-Table
Tree
Depth-First-Search
Breadth-First-Search
Sorting
Binary-Tree
LeetCode 314 note: BFS with a column index; BFS is what guarantees top-to-bottom within a column and left-to-right within a row
String
·7 mins
Algorithm
String
Simulation
Hash-Table
Simulation by building a list, parsing by trying every pattern at each position, all substrings of length k, counting by character class, checking balanced substrings from a fixed start, and splitting into words
Hash Table
·8 mins
Algorithm
Hash-Table
Counting
Array
Counting and frequency of frequencies, using the array itself as a hash table (sign marking), counting several keys at once (rows, columns, diagonals), incremental counts from a fixed left end, and grouping by a normalized key
LeetCode 305: Number of Islands II
·3 mins
LeetCode
Hard
Union-Find
Hash-Table
Array
LeetCode 305 note: each new land cell adds an island, then merges with neighboring land, subtracting 1 per successful merge; skip repeated positions
LeetCode 2584: Split the Array to Make Coprime Products
·3 mins
LeetCode
Hard
Math
Number-Theory
Sieve
Hash-Table
Array
LeetCode 2584 note: coprime products ⇔ no prime factor in both parts; record each prime’s last index, extend reach left to right, and split after i when reach == i