dsa-prep/readme.md

DSA Prep — Comprehensive Reference

Complete reference for Data Structures and Algorithms aligned with the Neetcode 150 weekly schedule. Each file is a deep dive with intuition, ASCII diagrams, Python (and C++ where useful) implementations, complexity a…

~4 min read·updated 5/29/2026

DSA Prep — Comprehensive Reference

Complete reference for Data Structures and Algorithms aligned with the Neetcode 150 weekly schedule. Each file is a deep dive with intuition, ASCII diagrams, Python (and C++ where useful) implementations, complexity analysis, and curated practice problems.

How to use this folder: open the file matching the current Neetcode week before you attempt the problems. Read the Concept and Pattern sections. Try problems first; come back to Pitfalls and Practice when stuck.


Index

#FileNeetcode WeekWhat You'll Learn
000-foundations.mdPre-weekBig O, complexity, Python/C++ idioms, math you'll need
101-arrays-hashing.mdWeek 1Arrays, strings, hashmaps, hashsets, frequency counting
202-two-pointers.mdWeek 2aOpposing/same-direction pointers, partitioning
303-sliding-window.mdWeek 2bFixed/variable windows, expand-shrink template
404-stack.mdWeek 3LIFO patterns, monotonic stack, parsing
505-binary-search.mdWeek 4Classic + variants, search-on-answer pattern
606-linked-list.mdWeek 5Pointers, cycles, reversal, dummy heads, LRU
707-trees.mdWeek 6-7aTraversals, recursion, BST, BFS, level-order
808-tries.mdWeek 7bPrefix tree, autocomplete, word search
909-heaps.mdWeek 8aPriority queue, top-K, two-heaps for medians
1010-backtracking.mdWeek 8bRecursion + undo, subsets, permutations, N-Queens
1111-graphs.mdWeek 9BFS/DFS, islands, topological sort, cycles
1212-advanced-graphs.mdWeek 10Dijkstra, Bellman-Ford, Union-Find, MST
1313-dp-1d.mdWeek 111D DP — top-down/bottom-up, decision trees
1414-dp-2d.mdWeek 12a2D DP — grids, knapsack, LCS, edit distance
1515-greedy-intervals.mdWeek 12bGreedy proofs, interval scheduling/merging
1616-bit-manipulation.mdWeek 12cBitwise ops, XOR tricks, bitmask DP
1717-patterns-cheatsheet.mdAll weeksOne-page lookup: "when do I use which pattern?"
1818-interview-strategy.mdPhase 3UMPIRE, communication, Google-specific tactics

How a problem unfolds (UMPIRE method)

Every interview problem should follow this sequence. The whole point of pattern recognition is to get from step U to step P quickly.

U — Understand     ── repeat the problem in your words; ask edge cases
M — Match          ── which pattern is this? (this folder is your dictionary)
P — Plan           ── pseudo-code, complexity estimate
I — Implement      ── write code in Python/C++
R — Review         ── trace through example, find off-by-ones
E — Evaluate       ── analyze actual O(n), discuss tradeoffs

See 18-interview-strategy.md for how to apply this in 45 minutes.


Pattern → Trigger Quick Lookup

If you can read a problem and match it to a pattern in <60 seconds, you're 80% of the way to solved. Memorize these triggers:

Trigger phrase / shapePatternFile
"find pair / triplet that sums to X" in sorted arrayTwo pointers02
"longest/shortest substring with property"Sliding window03
"next greater / previous smaller / span"Monotonic stack04
"search in sorted / find boundary"Binary search05
"minimize max / maximize min" feasibility checkBinary search on answer05
"cycle in linked list / find middle"Fast & slow pointers06
"all paths / all combinations / all permutations"Backtracking10
"shortest path in unweighted graph / grid"BFS11
"shortest path with weights ≥ 0"Dijkstra12
"shortest path, weights can be negative"Bellman-Ford12
"course schedule / dependency order"Topological sort11
"groups / connected components / merge sets"Union-Find12
"K most/least frequent / closest"Heap (top-K)09
"running median / two halves"Two heaps09
"decisions with overlapping subproblems"DP13/14
"merge / overlap / schedule intervals"Sort + sweep15
"all subsets containing X / no duplicates"Bitmask16

Full table with examples in 17-patterns-cheatsheet.md.


External resources used throughout

These are referenced across files. Bookmark them.


Notation used in these notes

SymbolMeaning
ninput size (length of array, number of nodes, etc.)
msecond dimension (cols of grid, length of pattern, etc.)
V, Evertices, edges of a graph
ka parameter ("top K", "K-sorted lists")
O(...)upper bound on time
Θ(...)tight bound (rare in interviews; usually O is enough)
Ω(...)lower bound (theoretical floor)
*amortized (e.g., dynamic array append is O(1)*)

Self-assessment after each topic

After finishing a file's problems, ask yourself:

  1. Can I write the template for this pattern from memory in 5 minutes?
  2. Can I name 3 problem variants and what they change?
  3. Can I state the complexity and prove it (not just memorize)?
  4. Can I explain when this pattern is wrong — what would force me elsewhere?

If "no" to any: re-read the file and re-do the failed problem in 3 days.

// 1 view

main
UTF-8·typescript