Learn
Practice notes for technical interviews
- Your story about explaining it to a manager never says what they decided
The non-technical stakeholder question is about the listener's decision. How to tell it with that decision, your first attempt and what changed.
- The diff only improves the error message, and now a coupon works twice
A small refactor that moves a condition out of an UPDATE, the two requests that expose it, and how to argue a race with evidence instead of a hunch.
- The overdue reminder went out for a book returned two minutes earlier
Keep a copy of the data a message needs, or read it when you send? What each costs, the case that breaks a copy, and the question that picks.
- They added a second part to the problem, and you rewrote the first in silence
When a multi-part round adds a requirement, say what stays, what changes and the one open question, then rerun the first part's example aloud.
- Your circular index works until it steps back from zero
In Java the remainder keeps the sign of the left side, so a ring index can become -1. The input that shows it, and a fix that holds for any step.
- Your fast solution agrees with every example you thought of
A seven-day practice order for checking a clever solution against a slow one you trust, and for finding the inputs you never think to try.
- You only looked up a key in your defaultdict, and now the key is there
Why a read or an emptied list can leave a key behind in a map of lists, the two-call input that shows it, and the invariant to say.
- Your weakness answer says you are working on it and never shows how
The weakness question is won or lost in the last sentence. How to end on a rule you follow and the last time it fired, not on a claim.
- The diff says it only simplifies the VAT code, and it changes the half pennies
A one-line refactor that swaps Decimal rounding for round(), the smallest input where the two disagree, and how to argue it with a test.
- Your seat hold ran out while the buyer was still paying
Hold a seat before payment or claim it after? What each design costs, the late payment that breaks a hold, and the question that picks.
- They asked you to walk them through it, and you read your code aloud
When the code works and the interviewer asks for a walkthrough, say the idea, the invariant, the one risky line and one traced input.
- You read the second item of your heap, and it was not the second smallest
Why only the first slot of a binary heap has a rank, the three-item input that shows it, and two honest ways to read the next k items.
- You found out twenty minutes in that the same value could appear twice
A seven-day practice order for asking, in the first two minutes, the one question whose answer changes your code, with what each day checks.
- Your loop said no after looking at only the first item
Why an else-return inside a search loop passes most samples, the two-item input that breaks it, and the one rule about when a loop may stop early.
- Your story spent two minutes on the background and twenty seconds on you
A behavioral answer that opens with the whole history runs out of time before your decision. How to cut the setup to two sentences and still be understood.
- The handler waits for two calls in turn, and neither needs the other's answer
A small async diff that is correct and slow, the one call that cannot move, and how to argue whether it matters.
- Your cache holds ten thousand entries, and nobody asked how many bytes that is
A limit on entries is not a memory budget. Two ways to bound an in-process cache, what each costs, and the question that picks.
- They asked SQL or NoSQL, and you answered with a definition
Turn the interviewer's numbers into rates aloud, say what they rule out, then let the rule your data must keep choose the database.
- Your memo remembers the position and forgets how many picks were left
Why a memo keyed on one argument of a two-argument recursion returns an answer to the wrong question, the five-item input that shows it, and the rule to say.
- An assistant has finished your lines for a year, and next week nothing will
A seven-day practice order for writing small code by hand again: the first-key case, the two-key sort, and saying each line before you type it.
- Your prefix-sum count is right until the target is zero
Why recording a running total before looking it up counts empty stretches, the one-element input that shows it, and the invariant to say.
- They asked for a time it happened, and you told them what you usually do
An answer in the present tense describes a habit, not an event. How to turn it into one dated story an interviewer can probe.
- The new cursor skips every post that shares a timestamp with the last one
A pagination change that loses rows without an error, the four-row input that shows it, and how to argue it is blocking.
- One viral post sends every like to the same database shard
Hashing spreads keys, not traffic. Two ways to split one hot counter, what each costs, and the question that picks between them.
- They asked you to write by hand what a library already does
How to say once that you would use a library at work, then turn a small parsing task into a list of input shapes you confirm aloud.
- Your rate limiter refuses the request that arrives exactly one window later
Why a sliding-log rate limiter is off by one at the edge of its window, the two-event input that shows it, and the invariant to say.
- Your first idea failed halfway through, and you went quiet until the end
A seven-day practice order for the moment your first approach breaks: name the input that broke it, what you keep, and what you try next.
- You keyed your set on an int array, and the same pair is counted twice
Why a Java HashSet of int arrays never finds a pair it already holds, the two-row input that shows it, and the sentence that makes a key safe.
- Your story says it got faster, and the next question is how you know
Every number in a behavioral story invites one follow-up. How to tell an impact story with a baseline, a cause and an effect you can defend.
- The fix reads the log one line at a time and still keeps every line
A memory fix that moves the growth from reading to keeping, the input that shows it, and how to keep an older bug out of the verdict.
- Does every player on the leaderboard need to know their exact rank?
One requirement, show each player their rank, two ways to meet it, what each costs, and the question that decides between them.
- Before you say the complexity, say what n is
A two-line function with two sizes hiding in it, why "n log n" is half an answer, and the four sentences that make a complexity claim checkable.
- You changed one cell of your grid and the whole column changed with it
Why a grid built by multiplying a list shares one row between all rows, the two-by-two input that shows it, and the sentence that rules it out.
- Your code review round is next week, and you have only practised writing code
A seven-day practice order for reading a diff you did not write, finding the defect that matters and arguing its severity with one input.
- Your sliding window works until one of the numbers is negative
Why a shrinking window misses a stretch that sums to the target once a value can be negative, the two-number input that shows it, and the fix.
- Your disagreement story should not end with you being proved right
A conflict story scores on how you disagreed and what you did once the call was made, not on who won. How to retell one so that part is visible.
- The test is named after two cases and checks only one of them
A one-line page-count fix, a test whose name promises more than its body checks, and the boundary input that exposes both.
- The app retried after a timeout, and the customer paid twice
One requirement, a retried payment must not charge again, two ways to meet it, what each costs, and the question that picks one.
- You saw a bug in your own code and fixed it without saying a word
A batching function that emits an empty batch, the one-item input that shows it, and the four sentences that turn a silent fix into evidence.
- Your counts match on every test until one of them reaches 128
Why == on two Integer values from a Java map works for small counts and fails at 128, the input that shows it, and the sentence to say instead.
- You only find your bugs after you press run
A seven-day practice order for tracing your own code by hand, with the three inputs that catch most loop bugs and what each day checks.
- Your solution has one loop and still runs in quadratic time
A membership check on a list hides a second loop. The input size that exposes it, how to spot it, and the sentence that states your real complexity.
- Your story about a mistake should contain a mistake you made
Most failure stories blame the ticket or end on a platitude. How to name your own call, what it cost, and the habit it changed.
- The bug in this diff is in a caller the diff never touched
A one-line change from a list to a generator, the unchanged caller it breaks, and how to argue a finding that sits outside the diff.
- You added read replicas, and now people cannot see the change they just saved
One requirement, read-your-own-writes, two ways to meet it, what each costs, and the one question that picks between them.
- Before you go quiet to think, say which question you are answering
One ambiguous word, the four-number input that exposes it, and the three sentences that turn a silent pause into evidence of how you think.
- Your comparator subtracts, and two large numbers sort the wrong way round
Why a - b in a Java comparator breaks on two values that fit in an int, the input that shows it, and the sentence that replaces it.
- You solved it last month and cannot start it again today
A seven-day practice order for problems you recognise but cannot rebuild from a blank file, with what each day checks.
- Your binary search forgot that the answer can be past the end
A lower-bound search that passes the sample and fails on a one-element array, and the two-line invariant that makes the bounds obvious.
- In a behavioral round, say the decision that was yours
A story told as "we did" hides the one thing the interviewer is scoring. How to find your own decision in it and retell it with its effect.
- In a code review round, lead with the defect that hurts someone
A six-line caching diff with three findings, and how to rank them by who gets hurt, when it shows, and whether it can be undone.
- Should the unread badge be counted when you read it or when mail arrives
One small requirement, two designs, the price of each, and the single question that tells you which one to draw first.
- A passing sample test is not the whole test
The sample input passes, you say "done", and the interviewer types an empty array. One exercise to catch the assumption you never said out loud.