Special Techniques and Misc Patterns

Power tools and edge-case solvers that don’t fit in a single category but frequently appear in real interviews.

1.0 Merge Intervals and Sweep Line

  1. Merge/insert intervals
  2. Meeting rooms
  3. Line sweep problems (min overlap)

2.0 Binary Search on Answer

  1. Minimum feasible value (ship capacity, days)
  2. Monotonic f(x) problems
  3. Minimize/maximize result over decision space

3.0 Sliding Window + Monotonic

  1. Maximum in window
  2. Min swaps to group elements
  3. Longest subarray under sum/condition

4.0 Reservoir Sampling & Randomized

  1. Pick random element with unknown N
  2. Shuffle array uniformly
  3. Randomized hashing

5.0 Simulation and State Machines

  1. Game of Life
  2. Spiral matrix
  3. Turing tape / DFA logic

6.0 Design + Iterator Patterns

  1. Nested Iterator
  2. Zigzag iterator
  3. Iterator for BST