ds · techniques

Browse by Technique

The lessons are organized by data structure; interviewers ask by pattern. 35 tags across 31 problems — pick the lens you need.

arrays 3 problems
  1. Two Sum

    easy
    time
    O(n)
    space
    O(n)

    arrays · hash-tables

  2. Maximum Subarray (Kadane's)

    medium
    time
    O(n)
    space
    O(1)

    arrays · dynamic-programming

  3. Trapping Rain Water

    hard
    time
    O(n)
    space
    O(1)

    arrays · two-pointer

linked-lists 4 problems
  1. Merge Two Sorted Linked Lists

    easy
    time
    O(n + m)
    space
    O(1)

    linked-lists · two-pointer

  2. Reverse a Linked List

    easy
    time
    O(n)
    space
    O(1)

    linked-lists · two-pointer

  3. Detect a Cycle (Floyd's Tortoise and Hare)

    medium
    time
    O(n)
    space
    O(1)

    linked-lists · two-pointer · cycle-detection

  4. Merge K Sorted Lists

    hard
    time
    O(n log k)
    space
    O(k)

    heaps · linked-lists · k-way-merge

stacks 4 problems
  1. Min Stack

    easy
    time
    O(1)
    space
    O(n)

    stacks · design

  2. Evaluate Postfix Expression

    medium
    time
    O(n)
    space
    O(n)

    stacks · parsing

  3. Next Greater Element

    medium
    time
    O(n)
    space
    O(n)

    stacks · monotonic-stack

  4. Queue from Two Stacks

    medium
    time
    O(1)
    space
    O(n)

    queues · stacks · design · amortized

queues 3 problems
  1. Queue from Two Stacks

    medium
    time
    O(1)
    space
    O(n)

    queues · stacks · design · amortized

  2. Bounded Ring Buffer (Robotics)

    medium
    time
    O(1)
    space
    O(capacity)

    queues · ring-buffer · robotics

  3. Sliding Window Maximum

    hard
    time
    O(n)
    space
    O(k)

    queues · monotonic-deque · sliding-window

trees 4 problems
  1. Is Binary Tree Height-Balanced?

    easy
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  2. Maximum Depth of Binary Tree

    easy
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  3. Binary Tree Level-Order Traversal

    medium
    time
    O(n)
    space
    O(w)

    trees · bfs

  4. Diameter of Binary Tree

    medium
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

bst 3 problems
  1. Lowest Common Ancestor in a BST

    easy
    time
    O(h)
    space
    O(1)

    bst · recursion

  2. Kth Smallest Element in a BST

    medium
    time
    O(h + k)
    space
    O(h)

    bst · in-order

  3. Validate Binary Search Tree

    medium
    time
    O(n)
    space
    O(h)

    bst · recursion · dfs

heaps 3 problems
  1. Top K Frequent Elements

    medium
    time
    O(n log k)
    space
    O(n)

    heaps · hash-tables · top-k

  2. Median of a Data Stream

    hard
    time
    O(log n) per insert, O(1) per query
    space
    O(n)

    heaps · two-heaps · streaming

  3. Merge K Sorted Lists

    hard
    time
    O(n log k)
    space
    O(k)

    heaps · linked-lists · k-way-merge

hash-tables 5 problems
  1. Two Sum

    easy
    time
    O(n)
    space
    O(n)

    arrays · hash-tables

  2. Group Anagrams

    medium
    time
    O(n · k)
    space
    O(n · k)

    hash-tables · strings · canonicalization

  3. Longest Substring Without Repeating Characters

    medium
    time
    O(n)
    space
    O(min(n, alphabet))

    hash-tables · sliding-window · strings

  4. LRU Cache

    medium
    time
    O(1)
    space
    O(capacity)

    hash-tables · doubly-linked-list · design

  5. Top K Frequent Elements

    medium
    time
    O(n log k)
    space
    O(n)

    heaps · hash-tables · top-k

graphs 3 problems
  1. Course Schedule (Topological Sort)

    medium
    time
    O(V + E)
    space
    O(V + E)

    graphs · topological-sort · cycle-detection

  2. Number of Islands

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · grid · dfs · connected-components

  3. Shortest Path in a Maze (BFS)

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · bfs · grid · shortest-path

dynamic-programming 4 problems
  1. Climbing Stairs

    easy
    time
    O(n)
    space
    O(1)

    dynamic-programming · recursion

  2. Coin Change

    medium
    time
    O(amount · |coins|)
    space
    O(amount)

    dynamic-programming

  3. Longest Common Subsequence

    medium
    time
    O(m · n)
    space
    O(min(m, n))

    dynamic-programming · strings

  4. Maximum Subarray (Kadane's)

    medium
    time
    O(n)
    space
    O(1)

    arrays · dynamic-programming

two-pointer 4 problems
  1. Merge Two Sorted Linked Lists

    easy
    time
    O(n + m)
    space
    O(1)

    linked-lists · two-pointer

  2. Reverse a Linked List

    easy
    time
    O(n)
    space
    O(1)

    linked-lists · two-pointer

  3. Detect a Cycle (Floyd's Tortoise and Hare)

    medium
    time
    O(n)
    space
    O(1)

    linked-lists · two-pointer · cycle-detection

  4. Trapping Rain Water

    hard
    time
    O(n)
    space
    O(1)

    arrays · two-pointer

sliding-window 2 problems
  1. Longest Substring Without Repeating Characters

    medium
    time
    O(n)
    space
    O(min(n, alphabet))

    hash-tables · sliding-window · strings

  2. Sliding Window Maximum

    hard
    time
    O(n)
    space
    O(k)

    queues · monotonic-deque · sliding-window

monotonic-stack 1 problem
  1. Next Greater Element

    medium
    time
    O(n)
    space
    O(n)

    stacks · monotonic-stack

monotonic-deque 1 problem
  1. Sliding Window Maximum

    hard
    time
    O(n)
    space
    O(k)

    queues · monotonic-deque · sliding-window

bfs 2 problems
  1. Binary Tree Level-Order Traversal

    medium
    time
    O(n)
    space
    O(w)

    trees · bfs

  2. Shortest Path in a Maze (BFS)

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · bfs · grid · shortest-path

dfs 5 problems
  1. Is Binary Tree Height-Balanced?

    easy
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  2. Maximum Depth of Binary Tree

    easy
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  3. Number of Islands

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · grid · dfs · connected-components

  4. Diameter of Binary Tree

    medium
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  5. Validate Binary Search Tree

    medium
    time
    O(n)
    space
    O(h)

    bst · recursion · dfs

recursion 6 problems
  1. Climbing Stairs

    easy
    time
    O(n)
    space
    O(1)

    dynamic-programming · recursion

  2. Is Binary Tree Height-Balanced?

    easy
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  3. Lowest Common Ancestor in a BST

    easy
    time
    O(h)
    space
    O(1)

    bst · recursion

  4. Maximum Depth of Binary Tree

    easy
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  5. Diameter of Binary Tree

    medium
    time
    O(n)
    space
    O(h)

    trees · recursion · dfs

  6. Validate Binary Search Tree

    medium
    time
    O(n)
    space
    O(h)

    bst · recursion · dfs

in-order 1 problem
  1. Kth Smallest Element in a BST

    medium
    time
    O(h + k)
    space
    O(h)

    bst · in-order

topological-sort 1 problem
  1. Course Schedule (Topological Sort)

    medium
    time
    O(V + E)
    space
    O(V + E)

    graphs · topological-sort · cycle-detection

connected-components 1 problem
  1. Number of Islands

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · grid · dfs · connected-components

cycle-detection 2 problems
  1. Course Schedule (Topological Sort)

    medium
    time
    O(V + E)
    space
    O(V + E)

    graphs · topological-sort · cycle-detection

  2. Detect a Cycle (Floyd's Tortoise and Hare)

    medium
    time
    O(n)
    space
    O(1)

    linked-lists · two-pointer · cycle-detection

top-k 1 problem
  1. Top K Frequent Elements

    medium
    time
    O(n log k)
    space
    O(n)

    heaps · hash-tables · top-k

two-heaps 1 problem
  1. Median of a Data Stream

    hard
    time
    O(log n) per insert, O(1) per query
    space
    O(n)

    heaps · two-heaps · streaming

k-way-merge 1 problem
  1. Merge K Sorted Lists

    hard
    time
    O(n log k)
    space
    O(k)

    heaps · linked-lists · k-way-merge

design 3 problems
  1. Min Stack

    easy
    time
    O(1)
    space
    O(n)

    stacks · design

  2. LRU Cache

    medium
    time
    O(1)
    space
    O(capacity)

    hash-tables · doubly-linked-list · design

  3. Queue from Two Stacks

    medium
    time
    O(1)
    space
    O(n)

    queues · stacks · design · amortized

strings 3 problems
  1. Group Anagrams

    medium
    time
    O(n · k)
    space
    O(n · k)

    hash-tables · strings · canonicalization

  2. Longest Common Subsequence

    medium
    time
    O(m · n)
    space
    O(min(m, n))

    dynamic-programming · strings

  3. Longest Substring Without Repeating Characters

    medium
    time
    O(n)
    space
    O(min(n, alphabet))

    hash-tables · sliding-window · strings

robotics 1 problem
  1. Bounded Ring Buffer (Robotics)

    medium
    time
    O(1)
    space
    O(capacity)

    queues · ring-buffer · robotics

streaming 1 problem
  1. Median of a Data Stream

    hard
    time
    O(log n) per insert, O(1) per query
    space
    O(n)

    heaps · two-heaps · streaming

amortized 1 problem
  1. Queue from Two Stacks

    medium
    time
    O(1)
    space
    O(n)

    queues · stacks · design · amortized

canonicalization 1 problem
  1. Group Anagrams

    medium
    time
    O(n · k)
    space
    O(n · k)

    hash-tables · strings · canonicalization

grid 2 problems
  1. Number of Islands

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · grid · dfs · connected-components

  2. Shortest Path in a Maze (BFS)

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · bfs · grid · shortest-path

shortest-path 1 problem
  1. Shortest Path in a Maze (BFS)

    medium
    time
    O(rows · cols)
    space
    O(rows · cols)

    graphs · bfs · grid · shortest-path

parsing 1 problem
  1. Evaluate Postfix Expression

    medium
    time
    O(n)
    space
    O(n)

    stacks · parsing

ring-buffer 1 problem
  1. Bounded Ring Buffer (Robotics)

    medium
    time
    O(1)
    space
    O(capacity)

    queues · ring-buffer · robotics

doubly-linked-list 1 problem
  1. LRU Cache

    medium
    time
    O(1)
    space
    O(capacity)

    hash-tables · doubly-linked-list · design