↓Skip to main content
Wei Yi Chung

Wei Yi Chung

Software Engineer @AICS

Recent

Greedy
·9 mins
Algorithm Greedy Sorting Intervals
Sort then scan, intervals sorted by right end, left and right passes, pairing and parity invariants, adjacent differences, and “remove what exceeds the average”, each with why greedy is correct
Heap and Priority Queue
·6 mins
Algorithm Heap Priority-Queue Greedy Dijkstra
heapq basics, Top-K, lazy deletion, two heaps, k-way merge, sweep line, and Dijkstra
Interval DP
·4 mins
Algorithm Dynamic-Programming Interval-Dp Memoization Binary-Search
Interval DP (choose the last step / merge equal ends), partition DP into k segments, palindrome tables plus partitioning, and memoizing the whole state when it is too tangled to split
Linear DP
·9 mins
Algorithm Dynamic-Programming State-Machine Monotonic-Queue Binary-Search
One-dimensional DP, state-machine DP, DP with a monotonic deque, interval scheduling DP after sorting, deduplicated subsequence counting, and DP-tagged problems where an observation or greedy is faster
Math
·10 mins
Algorithm Math Combinatorics Geometry Brainteaser
Combinatorial counting (pairs, ways to split), building the k-th permutation digit by digit, geometry (nearest point, law of cosines, triangle inequality), problems that become formulas after sorting or an observation, plus carry arithmetic, base conversion and fast exponentiation
Merge Sort and Divide-and-Conquer Counting
·7 mins
Algorithm Merge-Sort Divide-and-Conquer Sorting Counting
Merge sort templates, where to count in inversion-style problems, the linked list version, and common mistakes
Number Theory
·6 mins
Algorithm Math Number-Theory Prime Sieve Union-Find Gcd
GCD, primality tests, the sieve of Eratosthenes / linear sieve / smallest prime factor (SPF), connecting numbers by prime factors with Union-Find, and splitting an array by the last occurrence of prime factors
Queue and Design Problems
·3 mins
Algorithm Queue Design Iterator Lazy-Deletion
Circular queues, zigzag iterators, FIFO matching with cancellation, and the data structure combinations that design problems keep using
Stack and Monotonic Stack
·6 mins
Algorithm Stack Monotonic-Stack Greedy Simulation
Parsing nested structures, simulations that interact with the previous element, monotonic stacks, greedy deletion for the smallest string, and a lazy-deletion Max Stack
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
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
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