Module 01

Reading a Problem: Choosing the Right Tool

A repeatable triage for turning a wall of prose into 'oh, this is a monotonic stack'.

Practice — write these yourself

Every module ends with exercises. Write each one in the editor on its card and run it right here against the example, then copy the “Check my solution” prompt with your code into a fresh AI chat for a review. Reference solutions are behind a spoiler.

01

Triage three problems without coding

Warm-up

For each of these, write out triage steps 1–6 (no code). Identify the brute force, the wasted work, and the structure/pattern you'd reach for — plus the one phrase in the statement that gave it away.

  1. “Given an array of integers, return the length of the longest subarray whose elements sum to exactly k. Values can be negative. 1 ≤ n ≤ 2·10⁵.”
  2. “You're given n flights as (from, to, price) and a start city. Return the cheapest price to reach city t using at most k stops.”
  3. “Return all subsets of a set of n distinct integers. 1 ≤ n ≤ 16.”
Hints
    Check my reasoning · paste into a fresh AI chat
    02

    Complexity from constraints

    Warm-up

    Write a Go function that, given n, prints your target complexity and one candidate technique. Hard-code the reasoning as a lookup so you internalise the table. Then explain, in a comment, why n = 100000 rules out an O(n²) solution but n = 2000 allows it.

    implement this
    // targetComplexity returns (bigO, technique) you should aim for
    // given only the maximum input size n.
    func targetComplexity(n int) (string, string)
    main.go · runs in your browser
    Tab completes · Ctrl/⌘ + Enter runs
    Check my solution · paste into a fresh AI chat
    What the course does between lessons

    The part an AI chat can't give you

    An LLM will happily explain a monotonic stack — and you should let it. What it won't do is decide what you learn next, remember that you got something wrong three weeks ago, or put it back in front of you today. That machinery is the course.

    Review · try it
    card 1 / 5

    Think in half-open ranges [i,j); no …

    Real cards from the two free modules, scheduled by the same SM-2 code the course runs. Every module's key points become cards.

    Today

    Review 12 cards, then continue 14 Backtracking.

    The dashboard picks the one next thing, so you never open the course and wonder what to do.

    Problem → pattern
    • “sorted” + “find a pair”→Two pointers
    • “longest substring…”→Sliding window
    • “next greater element”→Monotonic stack
    • “top k” / “k closest”→Heap
    • “number of ways”→DP over states

    Two full indexes map the phrases you actually see in a problem to the structure or building block they imply. Browse the DSA one free →

    The rest of it

    That's 3 of 81.

    The rest of Data Structures & Algorithms, all of Broader CS, and the full System Design track — including 19 case studies you run as mock interviews — plus every exercise and the spaced-repetition review, are one payment away.

    Already bought it? Unlock