Algorithms
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
SQL Basics
·3 mins
Algorithm
Database
Sql
Combining conditions in SELECT … WHERE, and NULL’s three-valued logic: any comparison with NULL is not true, so use IS NULL
Segment Tree and Fenwick Tree
·3 mins
Algorithm
Segment-Tree
Binary-Indexed-Tree
Design
Point updates with range queries: a Fenwick tree (binary indexed tree) jumps by i & -i, and a segment tree recursively halves the range; both take O(log n) per operation
Matrix
·5 mins
Algorithm
Matrix
Simulation
Array
Transposing and rotating, converting between 2D indices and a 1D sequence, neighbors and diagonals, and spiral traversal with four boundaries
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
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
Bucket Sort and the Pigeonhole Principle
·2 mins
Algorithm
Bucket-Sort
Pigeonhole-Principle
Sorting
Split the value range into n - 1 buckets; the largest gap can never fall inside one bucket, so keeping each bucket’s minimum and maximum finds the maximum adjacent difference in linear time
Bit Manipulation
·5 mins
Algorithm
Bit-Manipulation
Common bit operations, AND only removes bits while OR only adds them, finding adjacent ones with n & (n » 1), and all-ones numbers 2^k - 1
Array Scanning
·7 mins
Algorithm
Array
Simulation
Enumeration
Adjacent comparisons and walking monotonic runs (uphill, downhill, hills and valleys), keeping prefix / suffix maximums and sums in one pass, enumerating pairs in small ranges, and breaking ties with tuple keys
Two Pointers
·9 mins
Algorithm
Two-Pointers
String
Sorting
Converging pointers, one pointer per sequence, skipping blanks to compare positions, counting pairs after sorting, and the in-place write pointer
Trie
·3 mins
Algorithm
Trie
String
Prefix
Bit-Manipulation
Building a Trie from nested dicts, counting on nodes, pairing it with DFS, and when a Trie is not actually needed
Tree Traversal and Common Techniques
·11 mins
Algorithm
Tree
Binary-Tree
Dfs
Bfs
Bst
DFS return values, BFS level order, BST bounds, climbing to the LCA, tree diameter, and leaf trimming