What they’re really asking
If you only remember one thing, say this in the first minute: “Before I ask the assistant anything, I’ll say the algorithm myself: shortest path on a grid is breadth-first search, linear in the number of cells. That gives me a yardstick for whatever it writes. I’ll ask for a narrow piece and test it on small cases I can check by hand. If it’s wrong twice, I’ll give it the failing case once, and if it’s still wrong I’ll write that part myself and say why.”
The rest of this page explains each part of that answer.
The question is not really about mazes. It asks: what do you do when the assistant is confidently wrong and the clock is running?
In a normal coding round, a wrong answer is your own, and you debug your own reasoning. Here a second author is in the room. The assistant is a chat tool backed by a large language model (LLM): a program trained on huge amounts of text and code that writes a plausible reply to what you type. Its wrong answers look as tidy and confident as its right ones. So the skill being tested is noticing, saying so, and switching strategy, instead of asking the same thing again and hoping.
Hello Interview relays an E7 (Senior Staff) candidate whose model kept giving wrong answers on a maze problem, so he wrote the code himself (Hello Interview). The internal bar it quotes, “Should use AI, but need to show you understand the code”, rewards exactly that.
Clarify first
- Grid format and size. Walls, start and end markers, and whether diagonal moves count. Assume four directions.
- What to return. Does a path exist, the shortest path length, or the path itself? Assume the shortest length, with -1 when the end can’t be reached.
- Constraints. What is the largest grid in the tests? Assume up to 1,000 × 1,000, so the solution must be linear in the number of cells.
- Edge cases the tests may hide. Start equals end, start is a wall, an empty grid.
- The assistant. Can it edit files? Reports say chat only, so you paste its code in yourself.
Answer
Words you need first
- Breadth-first search (BFS): explore every cell one step away, then every cell two steps away, and so on, using a queue. The first time you reach the end, you have the shortest path.
- Depth-first search (DFS): follow one direction as far as it goes, then back up. It finds a path, not the shortest one.
- Prompt: the instruction you type to the assistant.
Solve it in your head first
Say this before you prompt: “Shortest path on an unweighted grid is BFS from the start. I mark a cell visited when I put it on the queue, not when I take it off, otherwise the same cell can be queued many times. Time and memory are O(rows × columns).” Now you have a yardstick for the assistant’s answer.
The worked example: a 3 × 3 grid you can check by hand
Use a tiny grid with no walls, start at the top left, end at the bottom left:
S . .
. . .
E . .
The right answer is 2: down, down. Here is what each kind of answer returns, and what to say:
| What the code does | Returns | What to say in the interview |
|---|---|---|
| Correct BFS | 2 | ”Matches my hand answer.” |
| DFS that tries right, then down, then left, then up | 6 (right, right, down, down, left, left) | “That’s depth-first. It found a path, not the shortest one.” |
| BFS that marks visited when a cell leaves the queue | 2 here, but cells get queued many times | ”Correct on this grid, but on a 1,000 × 1,000 open grid the queue blows up. Mark on enqueue.” |
| Row and column swapped in the bounds check | Fine on square grids, wrong or crashing on a 2 × 5 grid | ”I’ll add a non-square grid test, because squares hide this.” |
A model can produce any of these. The 3 × 3 grid exposes the DFS answer in seconds, and two more tiny tests (a non-square grid, and a grid where the end is walled off) expose most of the rest.
Prompt narrowly, then check against your yardstick
Ask for exactly what you designed:
“Write BFS over grid []string from S to E, four directions, return steps or -1; mark visited on enqueue; no recursion.”
Then review for the usual wrong answers: DFS presented as shortest path, visited marked on dequeue, row and column swapped in the bounds checks, and a missing check that the start or end is a wall. Run it on a 1 × 1 grid, a blocked grid and the provided tests.
When it is wrong twice, stop prompting
Two wrong answers mean the model is missing something you know: the failing input, the exact output format, a constraint. Give it that once, with the failing case pasted. If the third answer is still wrong, say so and switch:
“I’ll write this part myself; it’s faster than another round of review.”
That is the reported E7 behavior, and it shows you can tell when the tool stops paying for itself. BFS on a grid is about 15 lines; typing it takes less time than reviewing a fourth draft.
Keep using the assistant for the parts it does well: test cases, an input parser, a printer that draws the path on the grid.
Keep talking
The hard part, candidates report, is keeping the dialogue going with the interviewer while also reading model output (Hello Interview). Say what you believe the bug in the AI’s answer is before you fix it: “It’s exploring depth-first; I’ll show you with the 3 × 3 grid.” That one sentence shows the interviewer your judgment, which is what they are grading.
Senior vs Staff
Overruling the assistant
Senior
- Names the algorithm and complexity first, spots the wrong answer from that, and switches to writing it by hand without losing time.
Staff
- Explains why the model failed (missing constraint, ambiguous format), fixes the prompt once, and decides deliberately which parts stay delegated.
Small-team version
A small team’s coding agent (an assistant that can edit files and run commands itself) will be confidently wrong several times a week. The habit that saves you is the same as in the round:
- Know the shape of the right answer before reading the generated one: the algorithm, the complexity, one case you can check by hand.
- Set a stopping rule. Two failed attempts, then a person writes it or narrows the task. Without a rule, an afternoon disappears into re-prompting, and an engineer’s afternoon costs more than the agent’s monthly seat.
- Record repeated failures. When the same mistake comes back, add it as a rule in
AGENTS.md(a file of standing instructions the agent reads at the start of every session) or as a test, so the next session starts with that context. - Track abandoned tasks. If you often give up on an agent task, the tasks are too big or the agent lacks context. That is usually fixable; the model is rarely the only problem.
Pitfalls
- Re-rolling the same prompt. Asking again without new information rarely gets a better answer, and it burns the clock.
- Accepting DFS output as “shortest” because the sample test passed. The sample grid may have only one path; the 3 × 3 open grid has many.
- Silently rewriting the code. If you don’t say why the assistant was wrong, the interviewer sees typing, not judgment.
- Giving up on the assistant for the rest of the round. Under-use is also reported as a negative; keep delegating the parts it gets right.
Go deeper
- Family walkthrough: AI-assisted coding round in a provided codebase, especially its follow-ups on wrong and invented answers.
- Practise catching a plausible wrong fix on Build Your Own Kafka-lite: the count-only recovery fix passes the length check and still corrupts payloads.