Coding Interviews

Turn a problem statement into an approach you can implement, test and defend. Work through six sessions, then try a mixed mock.

← All learning paths

Prerequisites: You can write functions, loops and basic collections in your chosen language.

These sessions link to existing lessons and exercises. Seven practice problems support execution in C++, Python, JavaScript and TypeScript. Other exercises still use your own IDE. Completion is a self-check, not a correctness grade.

Saved in this browser. Self-checks are separate from your scored interview results.

  1. Session 1 · To work through

    Read the contract before choosing a pattern

    State what a valid answer is and which complexity classes fit the input.

    Learn and practice

    Your exercise

    Before reading Two Sum’s explanation, write three clarifying questions, a brute-force approach and the reason a hash map helps. Implement both locally and compare their answers on small inputs.

    Before moving on

    • My questions cover duplicates, distinct indices and whether an answer exists.
    • I can explain why checking the complement before insertion avoids reusing one index.
    • I tested negative values and duplicate values, and explained expected time and extra space.
  2. Session 2 · To work through

    Make boundaries and progress explicit

    Explain the invariant that makes a search or window safe to shrink.

    Learn and practice

    Your exercise

    Trace an absent target through a rotated array. Then solve the substring problem and explain why moving the left boundary preserves validity. Change the input to contain repeated values and identify which search assumption breaks.

    Before moving on

    • Every loop iteration either returns or strictly reduces the remaining search.
    • I can name the valid window condition before writing its update code.
    • I can distinguish an unsupported variant from a bug in the original contract.
  3. Session 3 · To work through

    Choose the state that makes operations cheap

    Connect required operations to a stack, heap, map or linked structure.

    Learn and practice

    Your exercise

    Solve one of the three tasks, list every operation and its cost, then explain why a simpler structure becomes too expensive. For LRU, trace overwrite, access and eviction with capacity two.

    Before moving on

    • I distinguish worst-case, expected and amortized costs where relevant.
    • I can show which state changes on every operation.
    • My trace includes a boundary case such as equal values, touching intervals or an existing key.
  4. Session 4 · To work through

    Model connectivity and ordering

    Choose traversal or topological ordering from the question rather than its vocabulary.

    Learn and practice

    Your exercise

    Explain the graph hidden inside each problem. Solve one locally, test a disconnected input and a cycle, then describe what changes if the question asks for a shortest path.

    Before moving on

    • I define vertices and edges explicitly.
    • I know when a node becomes visited and why it cannot be counted twice.
    • I distinguish connectivity, dependency ordering and shortest paths.
  5. Session 5 · To work through

    Derive a recurrence instead of recalling code

    Define a state, transition, base case and evaluation order.

    Learn and practice

    Your exercise

    Write the meaning of one DP cell in a full sentence. Solve Coin Change, then change “minimum coins” to “number of combinations” and explain why the transition and iteration order need reconsideration.

    Before moving on

    • My state contains all information needed for the next decision.
    • Impossible states and the empty input have explicit meanings.
    • I can explain the altered counting problem without reusing an invalid recurrence.
  6. Session 6 · To work through

    Explain, test and handle a follow-up

    Keep your reasoning coherent when time is limited and requirements change.

    Learn and practice

    Your exercise

    Give yourself 45 minutes: clarify, describe a baseline, improve it, implement locally, test and explain one alternative. Record where you used help. Repeat later on a different problem.

    Before moving on

    • I tested my own code, rather than treating the mock’s rubric score as execution evidence.
    • I can explain correctness and complexity without the solution open.
    • I identified one specific weakness and chose a relevant next exercise.

Test transfer on something unfamiliar

Revisiting a solution tests recall. Choose a different problem, explain your assumptions and record what you still need help with.

Try a mixed mock interview →