CODING INTERVIEW PRACTICE

Practice the whole conversation, not just the code.

A good solution is only part of a technical interview. Practice asking useful questions, explaining trade-offs, checking edge cases, and responding when the problem changes. This 45-minute session gives you a repeatable way to work on all four.

A focused 45-minute practice session

  1. Minutes 0–5: make the problem precise. Restate the input and output. Ask about empty input, duplicate values, ordering, and whether changing the input is allowed. Write down one example before you choose a data structure.
  2. Minutes 5–12: explain a baseline. Describe the simplest correct solution. Identify the operation that repeats and estimate its time and extra-space cost. A baseline makes the reason for an optimization easier to explain.
  3. Minutes 12–27: improve and implement. Choose a data structure because it removes a specific repeated operation. State an invariant: what remains true before and after each iteration? Keep the implementation aligned with that explanation.
  4. Minutes 27–37: test and follow up. Walk through a normal case, an empty or minimal case, and a case that could break your assumption. Change one constraint and explain what would need to change.
  5. Minutes 37–45: review the conversation. Note one unclear explanation, one missed edge case, and one useful follow-up. Re-explain the solution without reading the code.

Try this original practice problem

Given a list of integers and a target, return two distinct indices whose values sum to the target. If no pair exists, return an empty list.

values = [3, 3], target = 6 → [0, 1]

Follow-up: why must you check for the complement before storing the current value?

A hash map can store values you have already seen and their indices. Checking first prevents reusing the current index. Expected time is O(n) with a typical hash table; extra space is O(n). Discuss the average-case assumption rather than calling every map lookup unconditionally constant.

Choose one part to improve today

Review with a simple rubric

  • Could another person explain the problem after hearing your restatement?
  • Did you give a reason for the data structure you chose?
  • Did your complexity claim account for allocation, recursion, and nested work?
  • Did you test the assumption most likely to fail?
  • Could you answer the follow-up without starting over?

Interview Roo can help you keep screenshots, captions, answers, and saved session history together during preparation. Review generated answers for correctness. For a live assessment, follow its rules and use assistance only when permitted.