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:

String Manipulation:

  • Coming soon…

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.