THN Interview Prep

Data Structures & Algorithms

Markdown-first mind map for pattern recognition, fast recall, and interview teaching: coding patterns, ~200+ problem write-ups, cheatsheets, and system design (under DSA as extended interview prep).

Quick orientation

DSA interviews reward structured thinking: name the pattern, state complexity, then refine. Use the sidebar: Patterns for recognition, Topics for deep problem pages, Cheatsheets for short recall, System design when the loop expands beyond LeetCode-style coding.

Understand concepts (not just solutions)

Each pattern is a reusable invariant: a rule that stays true while the algorithm moves. To learn clearly:

  1. Name the object — array index, window boundaries, stack top, tree node return value, heap ordering, etc.
  2. State the invariant — what is always true about “done” vs “unknown” work after each step?
  3. Prove the move — why is the next step safe? Which candidates can never be the answer after this move?
  4. Connect to complexity — each step should throw away a constant fraction of work (log), or touch each item a bounded number of times (linear).

If a problem page feels dense, read the matching pattern card first (same idea, less detail), then return to the problem’s diagram and “Understanding” sections.

Tiny vocabulary (shared across topics)

  • Asymptotic complexity — how work grows with input size; ignore constants but keep n vs log n vs n log n straight.
  • Amortized — some steps are expensive, but averaged over many operations the cost is still low (typical for hash tables and dynamic arrays).
  • Greedy vs optimal — greedy picks the locally best move; it is only correct when an exchange argument or problem structure proves local choices cannot block the global optimum.
  • State (DP / recursion) — the minimum summary of past decisions you need to continue; if you can describe it in a tuple, you can often tabulate it.

Mark this page when you finish learning it.

Last updated on

Spotted something unclear or wrong on this page?

On this page