From Wiki

DSA

Notes on data structures and algorithms, worked as I drill them. Each page is a pattern: the template, the problems that use it, and the complexity that makes the template worth reaching for.

The method I run on every problem:

  1. Restate the problem, name an edge case or two.
  2. State the brute force and its complexity out loud.
  3. Name the bottleneck. Why is it slow?
  4. Reach for the structure that kills the bottleneck: a sorted sweep, a heap, a hashmap, two pointers.
  5. Then write the code. Clean, running, tested on one example.

Roadmap

  • Intervals and sweep-line. Merge, insert, minimum rooms, non-overlapping. The template: sort the events, sweep a counter or a heap.
  • The common patterns. Two pointers, hashing, heaps, binary search, graph traversal. One clean rep each, so the pattern is nameable in the first minute.
  • Designing data structures. LRU cache, rate limiter, a hashmap from scratch. Problems that ask you to build a structure with given operations rather than solve a puzzle.