← Waymo Interview Insights

Waymo·Software Engineer·Technical Phone Screen·Senior

SeniorPrefer not to say
Jun 2026Remote

Summary

Waymo coding interview that started with a classic knight moves problem but pushed into the infinite board variant, which is where things got genuinely interesting. The bounded version felt manageable but the follow-up exposed some gaps in how I think about BFS on unbounded graphs.

Questions Asked (1)

Q1

On an infinite chessboard, a knight starts at (0, 0). Given a target coordinate (x, y), find the minimum number of moves for the knight to reach it.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

I jumped straight to BFS and it worked fine for small inputs.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying the problem: infinite board, knight moves in L-shape, find minimum moves. Then discuss BFS as a baseline, but note its inefficiency for large coordinates. Propose a mathematical/constant-time solution using symmetry and known patterns, and analyze trade-offs between BFS and formula-based approaches.

Pro tip: Mention that for large coordinates, BFS is impractical due to infinite board, so a closed-form solution is necessary. Also, highlight that the problem has known special cases (e.g., (1,0) requires 3 moves) that must be handled.

1. Clarify and Restate

Confirm the problem details: infinite board, knight moves, minimum moves. Ask if there are constraints on x and y (e.g., large values).

2. Baseline Approach: BFS

Explain that BFS from (0,0) can find the shortest path, but it's inefficient for large coordinates due to exploring many nodes. Mention that BFS works for small targets but not for infinite board.

3. Optimized Approach: Mathematical Formula

Propose using symmetry (absolute values, sort coordinates) and a closed-form solution. Derive or state the formula: if x < y, swap; if (x,y) == (1,0) return 3; if (x,y) == (2,2) return 4; else return max((x+1)/2, (x+y+2)/3) rounded up appropriately.

4. Handle Edge Cases and Validate

Discuss special cases like (0,0) -> 0, (1,0) -> 3, (2,2) -> 4. Validate the formula with examples and explain why it works (e.g., parity, board geometry).

5. Trade-offs and Complexity

Compare BFS (O(x*y) time, O(x*y) space) with formula (O(1) time and space). Discuss when BFS might be preferable (e.g., if obstacles are added) and the importance of constant-time solutions for large inputs.

Key Points to Mention

  • BFS is a natural but inefficient solution for infinite board; it's O(x*y) and impractical for large coordinates.
  • Symmetry reduces the problem: take absolute values and sort so that x >= y >= 0.
  • Special cases: (0,0) -> 0, (1,0) -> 3, (2,2) -> 4.
  • General formula: max(ceil(x/2), ceil((x+y)/3)) with adjustments for parity (e.g., if (x+y) % 2 != 0, add 1).
  • Time and space complexity: O(1) for formula, O(x*y) for BFS.
  • Trade-offs: formula is fast but less flexible; BFS can handle obstacles or variations.

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.