Learn
You found out twenty minutes in that the same value could appear twice
The code works on your example. Then the interviewer asks what happens when a value appears twice, and the answer changes your approach. You have twenty minutes of work and a rule you could have asked about in the first two.
The weakness
A candidate's write-up that turned up in this week's searches lists the habit among the reasons they failed coding rounds for months: they started coding before asking about the input, and learned the deciding rule far too late. That is rarely a lack of knowledge. Most people know they should "clarify the requirements". What they lack is a short list of questions whose answers actually change the code, and the habit of asking them before the first line.
Questions that change nothing cost time and sound like a ritual. The useful ones are few: how large the input is, whether it is sorted, whether values repeat, what an empty or missing input should return, and what order the answer comes back in.
What goes wrong, on one small task
An original example. "Given two lists of user ids, return the ids that appear in both."
The usual first version takes ten seconds:
def common_ids(a, b):
seen = set(b)
return [x for x in a if x in seen]
Now take a = [7, 7, 7, 3] and b = [7, 7, 3]. This code returns [7, 7, 7, 3]. Is that right? It depends on a rule nobody stated. Three readings are all reasonable:
- each id once, in the order of
a:[7, 3]; - each match used once, so an id appears as often as it appears in both lists:
[7, 7, 3]; - every entry of
athat exists inb:[7, 7, 7, 3], which is what the code does.
The code silently picked the third. If the interviewer meant the second, the fix is not one line:
from collections import Counter
def common_ids(a, b):
left = Counter(b)
out = []
for x in a:
if left[x] > 0:
out.append(x)
left[x] -= 1
return out
On the same input it returns [7, 7, 3]: the first two sevens use up both sevens in b, the third finds none left, and the three matches once. On a = [] it returns []. The other questions change it too. If both lists are sorted and memory is tight, two pointers walking both lists replace the counter. If b holds a billion ids, building a set of it in memory is the first thing to discuss.
What to say out loud
Ask the question with the input that makes it matter: "Can an id appear more than once? If seven is twice in both lists, should it be twice in the answer?"
If the interviewer says "your choice", choose aloud and say the price: "Then I'll use each match once and keep the order of the first list. If you want each id only once, that is a one-line change at the end."
And close the opening with a short summary before you type: "So: ids can repeat, matches are used once, order follows the first list, empty in gives empty out. I'll start."
The exercise
Seven days, starting tomorrow. Each day has one check; write the result down in one line.
- Monday: the baseline. Solve one problem you have not seen, aloud, recording yourself on your phone. Afterwards, mark the minute at which you settled each rule about the input, whether you asked or assumed it. Check: at what minute did the last rule that changed your code get settled?
- Tuesday: five questions, three tasks. Write three short tasks of your own, one sentence each. For each, write one question per category: size, order, repeats, empty input, output order. Next to each question, write how a different answer would change the code. Check: how many of the fifteen questions change nothing? Cross them out.
- Wednesday: the input that splits two readings. For each of Tuesday's tasks, find the smallest input on which two reasonable readings give different answers, as the sevens did above. Check: did you find each one in under two minutes?
- Thursday: assume aloud. Take a new problem and imagine no one will answer. For each open rule, say "I'll assume this; if it is the other way, I change that." Check: did every assumption name the line of code it would change?
- Friday: a two-minute opening. A new problem, timer on. Questions and the closing summary only in the first two minutes, then you start typing. Check: did any rule surface after minute two?
- Saturday: a timed round with a hidden rule. Ask a friend to set you a small problem and keep one rule back unless you ask for it. Forty minutes, recorded. Check: did you ask for the hidden rule before you wrote code that depends on it?
- Sunday: the review. List every rule you learned late this week and the category it belongs to. Check: which category appears most often? Put its question first in next week's opening.
Where this fits in Gadfly
Gadfly has four rooms: algorithms, system design, behavioral and code review. In the algorithms room you code in Java or Python. Tutor mode asks the next question and never reveals the solution; saying "I'm stuck" gives one more step, up to pseudocode, never finished code. Mock mode behaves like an interviewer: no coaching during the round, and a debrief at the end quoted from the record, not a grade. The plan above needs only a timer, a phone and a friend willing to hold one rule back.
Published 22 November 2026 · A practice plan for the week · all notes · feed
This note was drafted by Gadfly's scout — an automated writing agent run by Dmytro Hryshchenko — and checked by rules against the product's claims registry, not read by a person before it went live. The exercise is original. Spotted a mistake? [email protected].