Choose a coding problem and work through its contractLESSON 2.01 · 1 OF 43 IN CHAPTER
PART A / Coding problems and trade-offs
Step 27 of 252
LESSON 2.01 · 1 OF 43 IN CHAPTERGUIDED READING

Choose a coding problem and work through its contract

Your first complete attempt

Begin with Two sum. A reconciliation tool receives amounts such as [3,3] and asks for two distinct positions totaling 6. Write (0,1) before choosing the implementation, then explain why a single [3] cannot reuse its own position.

Repeat that method through the progression below: concrete result first, state and invariant next, then code and a changed requirement. This page is a route through exercises, not another algorithm you need to implement.

“I will give you a concrete input and a required output. Explain the contract, show a simple correct approach, then improve it and respond when a constraint changes.” That is the skill this route practices.

Start with one individual problem. Write the expected answer for its small example before opening the solution. Python is used for algorithms; TypeScript is used where browser state and asynchronous APIs are the problem.

42 individual problems

Each page supplies its contract, worked reasoning, visual traces and changed requirements, reference implementation, and meaningful tests. Build your own solution first; passing the reference tests alone does not assess you. The short concept lessons below are prerequisite refreshers, not the full question bank.

Follow the stages in order until you can explain and implement the prerequisite. Later stages broaden the bank; they are not a claim that every role asks every topic.

Stage Problems What the next stage relies on
1. Scan and remember 01–08: maps, windows, prefixes, arrays State an invariant; separate input size from retained state
2. Order and boundaries 09–13: intervals, binary and answer search Choose closed/half-open semantics and prove each boundary update
3. Identity and recursion 14–20: lists and trees Preserve links; distinguish a returned value from accumulated results
4. Graphs and retained state 21–30: scheduling, paths, heaps, caches, trie Discovery/finality rules; bounded state; operation sequences
5. Search and recurrence 31–36: backtracking and four DP exercises Define a subproblem, dependencies, base cases and proof
6. Advanced follow-ups 37–42: monotonic structures, parser, event time, median, queue Derive changed invariants; choose by role and interview format

After stages 1–3, add the importer debugging lab. After stage 4, add TypeScript fan-out and the runnable full-stack editor. Infrastructure candidates should also implement the bounded executor. Alternate familiar practice with unfamiliar assessed sessions.

To verify all supplied Python references without cross-importing their identically named modules, run python scripts/check_curriculum.py --coding-only from the repository root. Run python scripts/check_curriculum.py to include the local labs. These checks verify reference code; record your own independent attempts separately.

Concept refreshers

Step Learn → implement You can move on when…
1 Maps → Two Sum You explain lookup-before-insert
2 Windows → longest unique substring You trace abba correctly
3 Prefix sums → subarray sum K Zeros and negative values work
4 Sorted data → binary search, intervals You defend both boundary updates
5 Graphs → islands, prerequisite order You handle duplicate discovery and cycles
6 Heaps → top K, Dijkstra You skip stale candidates and explain ordering
7 Stack → next warmer day You prove the nested loop is O(n)
8 DP → minimum coins You derive the recurrence before coding
9 Search → word search, trie You undo state and mark complete words
10 State → LRU cache Reads, overwrites, and eviction preserve recency
11 TypeScript → concurrency and stale responses You test rejected work and out-of-order completion
12 Timed mock → feedback and repeat You solve, test, explain, and adapt without hints

Start today

Open Two sum. Clarify → trace → code → test → explain. Reattempt a missed problem the next day before adding another topic.

Junior: correctness, tests, complexity. Senior: add changed constraints and practical integration. Staff: keep the same coding fluency; add API ownership, failure boundaries, and migration tradeoffs. These are practice targets, not company-wide leveling rules.