Algorithms MOC
Algorithms MOC
Navigation note for 200 algorithm problems organized by category and difficulty.
This collection covers classic data structure and algorithm problems spanning arrays, trees, graphs, dynamic programming, and more. For a cross-cutting guide to recurring problem-solving techniques, see Common Solution Strategies.
Arrays
| Problem | Difficulty | Description |
|---|---|---|
| Non-Constructible Change | Easy | |
| Sorted Squared Array | Easy | |
| Tournament Winner | Easy | |
| Transpose Matrix | Easy | |
| Two Number Sum | Easy | |
| Validate Subsequence | Easy | |
| Array Of Products | Medium | |
| Best Seat | Medium | |
| First Duplicate Value | Medium | |
| Longest Peak | Medium | |
| Majority Element | Medium | |
| Merge Overlapping Intervals | Medium | |
| Missing Numbers | Medium | |
| Monotonic Array | Medium | |
| Move Element To End | Medium | |
| Smallest Difference | Medium | |
| Spiral Traverse | Medium | |
| Sweet And Savory | Medium | |
| Three Number Sum | Medium | |
| Zero Sum Subarray | Medium | |
| Count Squares | Hard | |
| Four Number Sum | Hard | |
| Knight Connection | Hard | |
| Largest Range | Hard | |
| Longest Subarray With Sum | Hard | |
| Min Rewards | Hard | |
| Subarray Sort | Hard | |
| Zigzag Traverse | Hard | |
| Apartment Hunting | Very Hard | |
| Calendar Matching | Very Hard | |
| Line Through Points | Very Hard | |
| Minimum Area Rectangle | Very Hard | |
| Waterfall Streams | Very Hard |
Binary Search Trees
| Problem | Difficulty | Description |
|---|---|---|
| Find Closest Value In BST | Easy | |
| BST Construction | Medium | |
| BST Traversal | Medium | |
| Find Kth Largest Value In BST | Medium | |
| Min-Height BST | Medium | |
| Reconstruct BST | Medium | |
| Same BSTs | Medium | |
| Validate BST | Medium | |
| Repair BST | Hard | |
| Right Smaller Than | Hard | |
| Sum BSTs | Hard | |
| Validate Three Nodes | Hard |
Binary Trees
| Problem | Difficulty | Description |
|---|---|---|
| Branch Sums | Easy | |
| Evaluate Expression Tree | Easy | |
| Invert Binary Tree | Easy | |
| Node Depths | Easy | |
| Binary Tree Diameter | Medium | |
| Find Successor | Medium | |
| Height Balanced Binary Tree | Medium | |
| Merge Binary Trees | Medium | |
| Split Binary Tree | Medium | |
| Symmetrical Tree | Medium | |
| Find Nodes Distance K | Hard | |
| Flatten Binary Tree | Hard | |
| Iterative In-order Traversal | Hard | |
| Max Path Sum In Binary Tree | Hard | |
| Right Sibling Tree | Hard | |
| All Kinds Of Node Depths | Very Hard | |
| Compare Leaf Traversal | Very Hard |
Dynamic Programming
| Problem | Difficulty | Description |
|---|---|---|
| Levenshtein Distance | Medium | |
| Max Subset Sum No Adjacent | Medium | |
| Min Number Of Coins For Change | Medium | |
| Number Of Ways To Make Change | Medium | |
| Number Of Ways To Traverse Graph | Medium | |
| Dice Throws | Hard | |
| Disk Stacking | Hard | |
| Juice Bottling | Hard | |
| Knapsack Problem | Hard | |
| Longest Common Subsequence | Hard | |
| Max Sum Increasing Subsequence | Hard | |
| Maximize Expression | Hard | |
| Maximum Sum Submatrix | Hard | |
| Min Number Of Jumps | Hard | |
| Numbers In Pi | Hard | |
| Water Area | Hard | |
| Longest Increasing Subsequence | Very Hard | |
| Longest String Chain | Very Hard | |
| Max Profit With K Transactions | Very Hard | |
| Palindrome Partitioning Min Cuts | Very Hard | |
| Square of Zeroes | Very Hard |
Famous Algorithms
| Problem | Difficulty | Description |
|---|---|---|
| Kadane's Algorithm | Medium | |
| Stable Internships | Medium | |
| Union Find | Medium | |
| Dijkstra's Algorithm | Hard | |
| Kruskal's Algorithm | Hard | |
| Topological Sort | Hard | |
| A* Algorithm | Very Hard | |
| Knuth-Morris-Pratt Algorithm | Very Hard | |
| Prim's Algorithm | Very Hard |
Graphs
| Problem | Difficulty | Description |
|---|---|---|
| Depth-First Search | Easy | |
| Breadth-First Search | Medium | |
| Cycle In Graph | Medium | |
| Minimum Passes Of Matrix | Medium | |
| Remove Islands | Medium | |
| River Sizes | Medium | |
| Single Cycle Check | Medium | |
| Two-Colorable | Medium | |
| Youngest Common Ancestor | Medium | |
| Boggle Board | Hard | |
| Detect Arbitrage | Hard | |
| Largest Island | Hard | |
| Rectangle Mania | Hard | |
| Airport Connections | Very Hard | |
| Two-Edge Connected Graph | Very Hard |
Greedy
| Problem | Difficulty | Description |
|---|---|---|
| Class Photos | Easy | |
| Minimum Waiting Time | Easy | |
| Optimal Freelancing | Easy | |
| Tandem Bicycle | Easy | |
| Task Assignment | Medium | |
| Valid Starting City | Medium |
Heaps
| Problem | Difficulty | Description |
|---|---|---|
| Min Heap Construction | Medium | |
| Continuous Median | Hard | |
| Laptop Rentals | Hard | |
| Sort K-Sorted Arrays | Hard | |
| Merge Sorted Arrays | Very Hard |
Linked Lists
| Problem | Difficulty | Description |
|---|---|---|
| Middle Node | Easy | |
| Remove Duplicates From Linked List | Easy | |
| Find Loop | Medium | |
| Linked List Construction | Medium | |
| Merge Linked Lists | Medium | |
| Merging Linked Lists | Medium | |
| Remove Kth Node From End | Medium | |
| Reverse Linked List | Medium | |
| Shift Linked List | Medium | |
| Sum of Linked Lists | Medium | |
| LRU Cache | Hard | |
| Linked List Palindrome | Hard | |
| Node Swap | Hard | |
| Rearrange Linked List | Hard | |
| Zip Linked List | Hard |
Recursion
Includes problems combining recursion with dynamic programming and backtracking.
| Problem | Difficulty | Description |
|---|---|---|
| Nth Fibonacci | Easy | |
| Product Sum | Easy | |
| Blackjack Probability | Medium | |
| Permutations | Medium | |
| Phone Number Mnemonics | Medium | |
| Powerset | Medium | |
| Reveal Minesweeper | Medium | |
| Staircase Traversal | Medium | |
| Generate Div Tags | Hard | |
| Interweaving Strings | Hard | |
| Lowest Common Manager | Hard | |
| Solve Sudoku | Hard | |
| Ambiguous Measurements | Very Hard | |
| Non-Attacking Queens | Very Hard | |
| Number Of Binary Tree Topologies | Very Hard |
Searching
| Problem | Difficulty | Description |
|---|---|---|
| Binary Search | Easy | |
| Find Three Largest Numbers | Easy | |
| Search In Sorted Matrix | Medium | |
| Index Equals Value | Hard | |
| Optimal Assembly Line | Hard | |
| Quickselect | Hard | |
| Search For Range | Hard | |
| Shifted Binary Search | Hard | |
| Median Of Two Sorted Arrays | Very Hard |
Sorting
| Problem | Difficulty | Description |
|---|---|---|
| Bubble Sort | Easy | |
| Insertion Sort | Easy | |
| Selection Sort | Easy | |
| Merge Sort | Medium | |
| Three Number Sort | Medium | |
| Count Inversions | Hard | |
| Heap Sort | Hard | |
| Quick Sort | Hard | |
| Radix Sort | Hard |
Stacks
| Problem | Difficulty | Description |
|---|---|---|
| Balanced Brackets | Medium | |
| Best Digits | Medium | |
| Colliding Asteroids | Medium | |
| Min Max Stack Construction | Medium | |
| Next Greater Element | Medium | |
| Reverse Polish Notation | Medium | |
| Sort Stack | Medium | |
| Sunset Views | Medium | |
| Largest Rectangle Under Skyline | Hard | |
| Longest Park | Hard | |
| Shorten Path | Hard |
Strings
| Problem | Difficulty | Description |
|---|---|---|
| Caesar Cipher Encryptor | Easy | |
| Common Characters | Easy | |
| First Non-Repeating Character | Easy | |
| Generate Document | Easy | |
| Palindrome Check | Easy | |
| Run-Length Encoding | Easy | |
| Semordnilap | Easy | |
| Group Anagrams | Medium | |
| Longest Palindromic Substring | Medium | |
| Longest Substring Without Duplicates | Medium | |
| Minimum Characters For Words | Medium | |
| One Edit | Medium | |
| Reverse Words In String | Medium | |
| Valid IP Addresses | Medium | |
| Longest Balanced Substring | Hard | |
| Pattern Matcher | Hard | |
| Smallest Substring Containing | Hard | |
| Underscorify Substring | Hard |
Tries
| Problem | Difficulty | Description |
|---|---|---|
| Longest Most Frequent Prefix | Medium | |
| Suffix Trie Construction | Medium | |
| Multi String Search | Hard | |
| Shortest Unique Prefixes | Hard | |
| Strings Made Up Of Strings | Hard |
Difficulty Overview
| Category | Easy | Medium | Hard | Very Hard | Total |
|---|---|---|---|---|---|
| Arrays | 6 | 14 | 8 | 5 | 33 |
| Binary Search Trees | 1 | 7 | 4 | 0 | 12 |
| Binary Trees | 4 | 6 | 5 | 2 | 17 |
| Dynamic Programming | 0 | 5 | 11 | 5 | 21 |
| Famous Algorithms | 0 | 3 | 3 | 3 | 9 |
| Graphs | 1 | 8 | 4 | 2 | 15 |
| Greedy | 4 | 2 | 0 | 0 | 6 |
| Heaps | 0 | 1 | 3 | 1 | 5 |
| Linked Lists | 2 | 8 | 5 | 0 | 15 |
| Recursion | 2 | 6 | 4 | 3 | 15 |
| Searching | 2 | 1 | 5 | 1 | 9 |
| Sorting | 3 | 2 | 4 | 0 | 9 |
| Stacks | 0 | 8 | 3 | 0 | 11 |
| Strings | 7 | 7 | 4 | 0 | 18 |
| Tries | 0 | 2 | 3 | 0 | 5 |
| Total | 32 | 80 | 66 | 22 | 200 |
System Design Application Index
This index maps algorithms from the categories above to the system design notes where each algorithm is a named mechanism. Each entry states the specific system property the algorithm enables — not just the link.
| Algorithm | System Design Note | System Property Enabled |
|---|---|---|
| lru-cache | Distributed-Cache | O(1) eviction — doubly linked list + hash map removes least-recently-used entry at capacity |
| suffix-trie-construction | Search-Autocomplete-Design | O(p) prefix lookup — autocomplete traverses the trie at prefix length p, not dataset size |
| binary-search | Consistent-Hashing | O(log V) ring navigation — sorted virtual node array lookup finds the first node >= key hash |
| min-heap-construction | dijkstras-algorithm | O(log V) priority extraction — shortest-path degrades from O((V+E)logV) to O(V^2) without a heap |
| min-heap-construction | Web-Crawler-Design | O(log n) crawl ordering — priority queue ranks URLs by importance score for budget-efficient crawling |
| union-find | kruskals-algorithm | O(alpha(n)) cycle detection — near-constant amortized check prevents cycles during MST edge processing |
| HyperLogLog | Distributed-Cache | O(log log n) cardinality estimation — Redis PFADD/PFCOUNT counts distinct elements at fixed 12 KB |
| Geohash | Distributed-Cache | O(1) proximity cache key — geohash cell string enables location-based driver/restaurant lookup |
| Geohash | Database-Sharding | Geographic data locality — geohash prefix as shard key groups same-neighborhood data together |
| Merkle-Tree | Database-Replication | O(log n) anti-entropy repair — Cassandra/DynamoDB identify diverged key ranges without full data transfer |
| Merkle-Tree | Web-Crawler-Design | O(log n) change detection — compare root hashes across crawl cycles; descend only into changed subtrees |
For the three cross-domain concept notes (HyperLogLog, Geohash, Merkle Tree), see the linked notes for algorithm theory, system design application context, and scope boundaries against related building-block notes.
Cross-Domain Lineage Chains
Each chain traces an algorithm data structure through to the system architecture property it enables.
| Chain | Lineage |
|---|---|
| Cache Eviction | lru-cache (O(1) doubly linked list + hash map) -> Distributed-Cache (LRU eviction policy) -> News-Feed-Design (celebrity fan-out cache layer) |
| Prefix Search | suffix-trie-construction (O(p) trie traversal) -> Search-Autocomplete-Design (top-K precomputed prefix lookup) |
| Shortest Path | min-heap-construction (priority queue) -> dijkstras-algorithm (O((V+E)logV) shortest path) -> Web-Crawler-Design (priority-ranked URL frontier) |
| Graph Spanning | union-find (O(alpha(n)) cycle detection) -> kruskals-algorithm (MST construction via Kruskal) |
| Ring Navigation | binary-search (O(log V) sorted lookup) -> Consistent-Hashing (virtual node ring) -> Database-Sharding (hash-ring key partitioning) |
| Cardinality Estimation | HyperLogLog (O(log log n) distinct count) -> Distributed-Cache (Redis PFADD/PFCOUNT at 12 KB fixed) |
| Spatial Indexing | Geohash (binary space partitioning) -> Distributed-Cache (location cache key) -> Database-Sharding (geographic shard key) |
| Integrity Repair | Merkle-Tree (O(log n) hash diff) -> Database-Replication (Cassandra anti-entropy) -> Web-Crawler-Design (content change detection) |