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

ProblemDifficultyDescription
Non-Constructible ChangeEasy
Sorted Squared ArrayEasy
Tournament WinnerEasy
Transpose MatrixEasy
Two Number SumEasy
Validate SubsequenceEasy
Array Of ProductsMedium
Best SeatMedium
First Duplicate ValueMedium
Longest PeakMedium
Majority ElementMedium
Merge Overlapping IntervalsMedium
Missing NumbersMedium
Monotonic ArrayMedium
Move Element To EndMedium
Smallest DifferenceMedium
Spiral TraverseMedium
Sweet And SavoryMedium
Three Number SumMedium
Zero Sum SubarrayMedium
Count SquaresHard
Four Number SumHard
Knight ConnectionHard
Largest RangeHard
Longest Subarray With SumHard
Min RewardsHard
Subarray SortHard
Zigzag TraverseHard
Apartment HuntingVery Hard
Calendar MatchingVery Hard
Line Through PointsVery Hard
Minimum Area RectangleVery Hard
Waterfall StreamsVery Hard

Binary Search Trees

ProblemDifficultyDescription
Find Closest Value In BSTEasy
BST ConstructionMedium
BST TraversalMedium
Find Kth Largest Value In BSTMedium
Min-Height BSTMedium
Reconstruct BSTMedium
Same BSTsMedium
Validate BSTMedium
Repair BSTHard
Right Smaller ThanHard
Sum BSTsHard
Validate Three NodesHard

Binary Trees

ProblemDifficultyDescription
Branch SumsEasy
Evaluate Expression TreeEasy
Invert Binary TreeEasy
Node DepthsEasy
Binary Tree DiameterMedium
Find SuccessorMedium
Height Balanced Binary TreeMedium
Merge Binary TreesMedium
Split Binary TreeMedium
Symmetrical TreeMedium
Find Nodes Distance KHard
Flatten Binary TreeHard
Iterative In-order TraversalHard
Max Path Sum In Binary TreeHard
Right Sibling TreeHard
All Kinds Of Node DepthsVery Hard
Compare Leaf TraversalVery Hard

Dynamic Programming

ProblemDifficultyDescription
Levenshtein DistanceMedium
Max Subset Sum No AdjacentMedium
Min Number Of Coins For ChangeMedium
Number Of Ways To Make ChangeMedium
Number Of Ways To Traverse GraphMedium
Dice ThrowsHard
Disk StackingHard
Juice BottlingHard
Knapsack ProblemHard
Longest Common SubsequenceHard
Max Sum Increasing SubsequenceHard
Maximize ExpressionHard
Maximum Sum SubmatrixHard
Min Number Of JumpsHard
Numbers In PiHard
Water AreaHard
Longest Increasing SubsequenceVery Hard
Longest String ChainVery Hard
Max Profit With K TransactionsVery Hard
Palindrome Partitioning Min CutsVery Hard
Square of ZeroesVery Hard

Famous Algorithms

ProblemDifficultyDescription
Kadane's AlgorithmMedium
Stable InternshipsMedium
Union FindMedium
Dijkstra's AlgorithmHard
Kruskal's AlgorithmHard
Topological SortHard
A* AlgorithmVery Hard
Knuth-Morris-Pratt AlgorithmVery Hard
Prim's AlgorithmVery Hard

Graphs

ProblemDifficultyDescription
Depth-First SearchEasy
Breadth-First SearchMedium
Cycle In GraphMedium
Minimum Passes Of MatrixMedium
Remove IslandsMedium
River SizesMedium
Single Cycle CheckMedium
Two-ColorableMedium
Youngest Common AncestorMedium
Boggle BoardHard
Detect ArbitrageHard
Largest IslandHard
Rectangle ManiaHard
Airport ConnectionsVery Hard
Two-Edge Connected GraphVery Hard

Greedy

ProblemDifficultyDescription
Class PhotosEasy
Minimum Waiting TimeEasy
Optimal FreelancingEasy
Tandem BicycleEasy
Task AssignmentMedium
Valid Starting CityMedium

Heaps

ProblemDifficultyDescription
Min Heap ConstructionMedium
Continuous MedianHard
Laptop RentalsHard
Sort K-Sorted ArraysHard
Merge Sorted ArraysVery Hard

Linked Lists

ProblemDifficultyDescription
Middle NodeEasy
Remove Duplicates From Linked ListEasy
Find LoopMedium
Linked List ConstructionMedium
Merge Linked ListsMedium
Merging Linked ListsMedium
Remove Kth Node From EndMedium
Reverse Linked ListMedium
Shift Linked ListMedium
Sum of Linked ListsMedium
LRU CacheHard
Linked List PalindromeHard
Node SwapHard
Rearrange Linked ListHard
Zip Linked ListHard

Recursion

Includes problems combining recursion with dynamic programming and backtracking.

ProblemDifficultyDescription
Nth FibonacciEasy
Product SumEasy
Blackjack ProbabilityMedium
PermutationsMedium
Phone Number MnemonicsMedium
PowersetMedium
Reveal MinesweeperMedium
Staircase TraversalMedium
Generate Div TagsHard
Interweaving StringsHard
Lowest Common ManagerHard
Solve SudokuHard
Ambiguous MeasurementsVery Hard
Non-Attacking QueensVery Hard
Number Of Binary Tree TopologiesVery Hard

Searching

ProblemDifficultyDescription
Binary SearchEasy
Find Three Largest NumbersEasy
Search In Sorted MatrixMedium
Index Equals ValueHard
Optimal Assembly LineHard
QuickselectHard
Search For RangeHard
Shifted Binary SearchHard
Median Of Two Sorted ArraysVery Hard

Sorting

ProblemDifficultyDescription
Bubble SortEasy
Insertion SortEasy
Selection SortEasy
Merge SortMedium
Three Number SortMedium
Count InversionsHard
Heap SortHard
Quick SortHard
Radix SortHard

Stacks

ProblemDifficultyDescription
Balanced BracketsMedium
Best DigitsMedium
Colliding AsteroidsMedium
Min Max Stack ConstructionMedium
Next Greater ElementMedium
Reverse Polish NotationMedium
Sort StackMedium
Sunset ViewsMedium
Largest Rectangle Under SkylineHard
Longest ParkHard
Shorten PathHard

Strings

ProblemDifficultyDescription
Caesar Cipher EncryptorEasy
Common CharactersEasy
First Non-Repeating CharacterEasy
Generate DocumentEasy
Palindrome CheckEasy
Run-Length EncodingEasy
SemordnilapEasy
Group AnagramsMedium
Longest Palindromic SubstringMedium
Longest Substring Without DuplicatesMedium
Minimum Characters For WordsMedium
One EditMedium
Reverse Words In StringMedium
Valid IP AddressesMedium
Longest Balanced SubstringHard
Pattern MatcherHard
Smallest Substring ContainingHard
Underscorify SubstringHard

Tries

ProblemDifficultyDescription
Longest Most Frequent PrefixMedium
Suffix Trie ConstructionMedium
Multi String SearchHard
Shortest Unique PrefixesHard
Strings Made Up Of StringsHard

Difficulty Overview

CategoryEasyMediumHardVery HardTotal
Arrays6148533
Binary Search Trees174012
Binary Trees465217
Dynamic Programming0511521
Famous Algorithms03339
Graphs184215
Greedy42006
Heaps01315
Linked Lists285015
Recursion264315
Searching21519
Sorting32409
Stacks083011
Strings774018
Tries02305
Total32806622200

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.

AlgorithmSystem Design NoteSystem Property Enabled
lru-cacheDistributed-CacheO(1) eviction — doubly linked list + hash map removes least-recently-used entry at capacity
suffix-trie-constructionSearch-Autocomplete-DesignO(p) prefix lookup — autocomplete traverses the trie at prefix length p, not dataset size
binary-searchConsistent-HashingO(log V) ring navigation — sorted virtual node array lookup finds the first node >= key hash
min-heap-constructiondijkstras-algorithmO(log V) priority extraction — shortest-path degrades from O((V+E)logV) to O(V^2) without a heap
min-heap-constructionWeb-Crawler-DesignO(log n) crawl ordering — priority queue ranks URLs by importance score for budget-efficient crawling
union-findkruskals-algorithmO(alpha(n)) cycle detection — near-constant amortized check prevents cycles during MST edge processing
HyperLogLogDistributed-CacheO(log log n) cardinality estimation — Redis PFADD/PFCOUNT counts distinct elements at fixed 12 KB
GeohashDistributed-CacheO(1) proximity cache key — geohash cell string enables location-based driver/restaurant lookup
GeohashDatabase-ShardingGeographic data locality — geohash prefix as shard key groups same-neighborhood data together
Merkle-TreeDatabase-ReplicationO(log n) anti-entropy repair — Cassandra/DynamoDB identify diverged key ranges without full data transfer
Merkle-TreeWeb-Crawler-DesignO(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.

ChainLineage
Cache Evictionlru-cache (O(1) doubly linked list + hash map) -> Distributed-Cache (LRU eviction policy) -> News-Feed-Design (celebrity fan-out cache layer)
Prefix Searchsuffix-trie-construction (O(p) trie traversal) -> Search-Autocomplete-Design (top-K precomputed prefix lookup)
Shortest Pathmin-heap-construction (priority queue) -> dijkstras-algorithm (O((V+E)logV) shortest path) -> Web-Crawler-Design (priority-ranked URL frontier)
Graph Spanningunion-find (O(alpha(n)) cycle detection) -> kruskals-algorithm (MST construction via Kruskal)
Ring Navigationbinary-search (O(log V) sorted lookup) -> Consistent-Hashing (virtual node ring) -> Database-Sharding (hash-ring key partitioning)
Cardinality EstimationHyperLogLog (O(log log n) distinct count) -> Distributed-Cache (Redis PFADD/PFCOUNT at 12 KB fixed)
Spatial IndexingGeohash (binary space partitioning) -> Distributed-Cache (location cache key) -> Database-Sharding (geographic shard key)
Integrity RepairMerkle-Tree (O(log n) hash diff) -> Database-Replication (Cassandra anti-entropy) -> Web-Crawler-Design (content change detection)