Two Sum
The hash table trick that makes O(n²) become O(n) and why this pattern appears everywhere from feature stores to embedding lookups.
A comprehensive collection of data structures and algorithms problems, from fundamentals to advanced topics. Each problem explores multiple solutions, complexity analysis, and real-world applications.
Each problem includes:
Arrays & Hash Tables:
Stacks:
Linked Lists:
Design:
Dynamic Programming:
Trees & Graphs:
Sorting & Searching:
Two Pointers & Greedy:
Backtracking:
String Manipulation & Hash Tables:
Intervals:
Matrix & In-place Algorithms:
Below you’ll find all DSA problems in chronological order:
Content created with the assistance of large language models and reviewed for technical accuracy.
The hash table trick that makes O(n²) become O(n) and why this pattern appears everywhere from feature stores to embedding lookups.
Why a simple stack solves bracket matching, expression parsing, and even neural network depth management in one elegant pattern.
The pointer manipulation pattern that powers merge sort, data pipeline merging, and multi-source stream processing.
The single-pass pattern that powers streaming analytics, online algorithms, and real-time decision making in production systems.
Master the pattern behind online algorithms, streaming analytics, and dynamic programming, a single elegant idea powering countless production systems.
The Fibonacci problem in disguise, teaching the fundamental transition from recursion to dynamic programming to space optimization.
Master the fundamental patterns of tree traversal: the gateway to solving hundreds of tree problems in interviews.
Master BST validation to understand data integrity in tree structures, critical for indexing and search systems.
Master binary search to understand logarithmic algorithms and efficient searching, foundational for optimization and search systems.
Master linked list manipulation through reversal - a fundamental pattern for understanding pointer logic and in-place algorithms.
Master LRU cache design: O(1) get/put with hash map + doubly linked list. Critical for interviews and production caching systems.
Master digit-by-digit addition with linked lists: Handle carry propagation elegantly. Classic problem teaching pointer manipulation and edge cases.
Master the two-pointer greedy technique that powers resource optimization in production ML systems.
Master backtracking to generate all valid combinations—the foundation of ensemble model selection and multi-model systems.
Master hash-based grouping to solve anagrams—the foundation of clustering systems and speaker diarization in production ML.
Master interval processing to handle overlapping ranges—the foundation of event streams and temporal reasoning in production systems.
Simulate arbitrary-precision addition on linked lists—the same sequential pattern used in large-scale distributed training and streaming pipelines.
Master in-place matrix rotation—the same 2D transformation pattern that powers image and spectrogram augmentations in modern ML systems.
Master systematic matrix traversal—the same pattern used for tracking experiments, processing logs, and managing state in ML systems.
Master greedy decision-making to determine reachability—the same adaptive strategy used in online learning and real-time speech systems.
Master grid path counting with dynamic programming—the same optimization technique used in neural architecture search and speech model design.
The classic grid optimization problem that bridges the gap between simple recursion and 2D Dynamic Programming.
A deceptive counting problem that teaches the fundamentals of state transitions and connects directly to Beam Search.
The fundamental string segmentation problem that powers spell checkers, search engines, and tokenizers.