Data Structures & Algorithms

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:

  • Multiple approaches (brute force → optimal)
  • Time and space complexity analysis
  • Production engineering considerations
  • Connections to machine learning systems
  • Code examples and edge cases

Browse by Topic

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:


Problem Index

Below you’ll find all DSA problems in chronological order:


Content created with the assistance of large language models and reviewed for technical accuracy.

Two Sum

27 minute read

The hash table trick that makes O(n²) become O(n) and why this pattern appears everywhere from feature stores to embedding lookups.

Valid Parentheses

24 minute read

Why a simple stack solves bracket matching, expression parsing, and even neural network depth management in one elegant pattern.

Merge Two Sorted Lists

29 minute read

The pointer manipulation pattern that powers merge sort, data pipeline merging, and multi-source stream processing.

Best Time to Buy and Sell Stock

24 minute read

The single-pass pattern that powers streaming analytics, online algorithms, and real-time decision making in production systems.

Maximum Subarray (Kadane’s Algorithm)

23 minute read

Master the pattern behind online algorithms, streaming analytics, and dynamic programming, a single elegant idea powering countless production systems.

Climbing Stairs

25 minute read

The Fibonacci problem in disguise, teaching the fundamental transition from recursion to dynamic programming to space optimization.

Binary Tree Traversal

26 minute read

Master the fundamental patterns of tree traversal: the gateway to solving hundreds of tree problems in interviews.

Validate Binary Search Tree

23 minute read

Master BST validation to understand data integrity in tree structures, critical for indexing and search systems.

Binary Search

28 minute read

Master binary search to understand logarithmic algorithms and efficient searching, foundational for optimization and search systems.

Reverse Linked List

27 minute read

Master linked list manipulation through reversal - a fundamental pattern for understanding pointer logic and in-place algorithms.

LRU Cache

27 minute read

Master LRU cache design: O(1) get/put with hash map + doubly linked list. Critical for interviews and production caching systems.

Add Two Numbers

23 minute read

Master digit-by-digit addition with linked lists: Handle carry propagation elegantly. Classic problem teaching pointer manipulation and edge cases.

Container With Most Water

24 minute read

Master the two-pointer greedy technique that powers resource optimization in production ML systems.

Generate Parentheses

24 minute read

Master backtracking to generate all valid combinations—the foundation of ensemble model selection and multi-model systems.

Group Anagrams

24 minute read

Master hash-based grouping to solve anagrams—the foundation of clustering systems and speaker diarization in production ML.

Merge Intervals

21 minute read

Master interval processing to handle overlapping ranges—the foundation of event streams and temporal reasoning in production systems.

Add Two Numbers (Linked List)

13 minute read

Simulate arbitrary-precision addition on linked lists—the same sequential pattern used in large-scale distributed training and streaming pipelines.

Rotate Image

13 minute read

Master in-place matrix rotation—the same 2D transformation pattern that powers image and spectrogram augmentations in modern ML systems.

Spiral Matrix

13 minute read

Master systematic matrix traversal—the same pattern used for tracking experiments, processing logs, and managing state in ML systems.

Jump Game

24 minute read

Master greedy decision-making to determine reachability—the same adaptive strategy used in online learning and real-time speech systems.

Unique Paths

23 minute read

Master grid path counting with dynamic programming—the same optimization technique used in neural architecture search and speech model design.

Minimum Path Sum

21 minute read

The classic grid optimization problem that bridges the gap between simple recursion and 2D Dynamic Programming.

Decode Ways

16 minute read

A deceptive counting problem that teaches the fundamentals of state transitions and connects directly to Beam Search.

Word Break

20 minute read

The fundamental string segmentation problem that powers spell checkers, search engines, and tokenizers.