DSA Crash Course
Foundation Data Structures

Foundation Data Structures — Overview

Mark when done:

Phase 1 — Foundation Data Structures (Days 4-12)

Goal: Build a working knowledge of the seven data structures every coding interview assumes you understand. By the end of this phase you can pick the right structure for a problem in under 30 seconds.

Pre-req: Phase 0 (computational thinking + Big-O + recursion).

What You'll Cover

#ModuleDaysWhat you build
1.1Arrays & Strings4-5HashMap pattern, Kadane's algorithm, two pointers on sorted arrays
1.2Prefix Sum5The "subarray sum = K" insight — prefix-sum + HashMap
1.3Matrix6Spiral traversal, in-place rotation, grid DFS
1.4Hash Maps6Group anagrams (sorted-key trick), longest consecutive sequence
1.5Linked Lists7Reversal, cycle detection (Floyd's), LRU cache (map + doubly-linked list)
1.6Stacks & Queues8Monotonic stack, two-stack queue, basic calculator
1.7Trees9-10Recursive traversals, BFS level order, BST validation, serialize/deserialize
1.8Heaps11K-th largest, top-K frequent, two-heap median, K-way merge
1.9Graphs12Number of islands (DFS flood-fill), course schedule (topo sort), Pacific-Atlantic

How to Work Each Module

1. Open the module README. Read the "Deep Dive" + "Before You Start".
2. Open problems/XX-name.py. Try BRUTE FORCE first.
3. Stuck > 20 min  → read Hint 1, try 10 min.
4. Still stuck     → read Hint 2, try 10 min.
5. Still stuck     → check solutions/XX-name.py, study the approach,
                     then re-code it from memory.
6. Fill in TIME / SPACE complexity in the file. Write a NOTES line
   on what the trick was.
7. On the site, mark the problem Got it / Review / Struggled.
   "Struggled" items resurface on a 1-3-7-14 day spaced schedule.

Why This Phase Matters

Every later phase assumes you can reach for the right data structure without thinking. Phase 2 ("here's a paradigm") only makes sense if you already know which structure to apply it to. Phase 3 (pattern recognition) demands instant identification — and the patterns themselves are named after the structures (heap, two-pointers, monotonic stack).

If you skip a module here, you will pay for it twice: once when the next phase's problems feel impossible, and again when you have to back-fill anyway.


External Resources (Hand-Picked Supplements)