AO
Back

Shortest Path on Chess Board (BFS)

Phone ScreenPhone ScreenLast reported April 2026Low Frequency

Problem Overview

The round is one problem with two graded follow-ups, on the 45-minute phone screen. One report. The candidate had to define the function signature, write main, and write their own test cases in Java, lost minutes to a syntax slip in that boilerplate, finished bug-free with fifteen minutes left, answered both follow-ups, and was rejected the next day. The interviewer was silent while the candidate coded.

Find the fewest moves for a knight between two squares.

Given — the shape one candidate defined

def min_knight_moves(n: int, start: tuple[int, int], target: tuple[int, int]) -> int:
    """Fewest moves on an n x n board, or -1 if unreachable."""

Part 1 — a fixed board

Say why breadth-first beats depth-first for a shortest path, then search level by level with a visited set and a bounds check. Return the level at which the target appears.

Part 2 — blocked squares

Reported follow-up: some squares cannot be entered. Accept a blocked set and add one membership test to the neighbour filter, including the case where the start or target is blocked.

Part 3 — an infinite board

Reported follow-up: no bounds at all. Translate the start to the origin and fold positions into the first quadrant by symmetry; one reply adds that coordinates must be allowed slightly negative near the origin or short paths are missed.

The reported wall — the scaffolding. The search is textbook. What cost time was writing a runnable program from nothing, and what cost the round is unknown, since the code was clean and the follow-ups were answered.

Follow-up Arc

Interviewers escalate through these phases. The order varies, but most candidates see at least one from each bucket.
Concurrency · 1Trade-off discussion · 1
Concurrency

What if some cells on the board are blocked/impassable? How would you modify your solution?

Probes for: After base solution is working correctly
Trade-off discussion

What if the chess board is infinitely large? How would you handle that?

Probes for: After blockage follow-up

Approach Trade-offs

Approaches actually attempted in reports — including ones that lost candidates time. Pick deliberately.
ApproachNotes
DFSDoes not guarantee shortest path; may explore deep paths unnecessarily. Simpler to implement recursively but wrong for shortest-path problems.
BFS with symmetry optimizationConvert (x, y) to first quadrant using symmetry to reduce state space; also allow slightly negative coordinates (e.g., -2) to handle edge cases near the origin. Harder to think of under interview pressure.

What Reports Emphasize

Common mistakes: Adding 'static' to the outer class definition in Java caused a syntax error that took significant time to debug; the interviewer had to hint at the fix.; Being out of practice writing a full Java file from scratch (main(), class definitions, test cases) led to avoidable syntax errors under time pressure.

Interviewer hints: The interviewer was largely silent/muted during the coding portion and only became interactive during the follow-up discussion phase.; The interviewer helped point out the Java 'static outer class' syntax error when the candidate was stuck.

What passers do: Candidate briefly analyzed DFS vs. BFS tradeoffs before committing to BFS, which the interviewer expected as part of the problem setup.; Candidate achieved a bug-free solution with ~15 minutes remaining, leaving enough time to discuss both follow-ups.

Practice

Write your own against 7 test cases, or read the worked solution — approach, complexity, and code that runs.
Waymo · Phone Screen · Reported 1× across candidate reports
Is this helpful?