← Waymo Interview Insights

Waymo·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Waymo SWE interview with a knight moves problem on a partially blocked chessboard. Pretty clean algorithmic round, nothing too wild, though the edge cases are where things get interesting.

Questions Asked (1)

Q1

Given an N x N chessboard with some blocked cells, a knight's start position, and a target position, find the minimum number of moves for the knight to reach the target. Return -1 if it's unreachable. The knight can jump over blocked cells but cannot land on them.

Algorithms & Data Structures
Author's notes

BFS was the obvious move here (pun intended).

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Model the chessboard as a graph where each cell is a node and knight moves are edges, then use BFS to find the shortest path from start to target. Since all moves have equal weight, BFS guarantees the minimum number of moves, and we can return -1 if the target is never reached.

Pro tip: Precompute the 8 knight move offsets and use a visited matrix to avoid revisiting cells, which keeps the solution O(N^2) and prevents infinite loops. Also, early return if start equals target (0 moves) or if either is blocked (immediate -1).

1. Clarify and Validate Inputs

Confirm the board size, blocked cells representation, and start/target coordinates. Check edge cases: start or target blocked, start equals target, or out-of-bounds.

2. Model as Graph and Choose BFS

Treat each unblocked cell as a node and knight moves as edges. Explain that BFS is ideal because all edges have unit weight, ensuring the shortest path in moves.

3. Implement BFS with Queue and Visited Set

Use a queue to process cells level by level, tracking distance. Mark cells as visited when enqueued to avoid duplicates. For each cell, generate all 8 knight moves, filter out invalid or blocked cells.

4. Return Result and Analyze Complexity

If target is reached, return the distance; if queue empties, return -1. State time and space complexity: O(N^2) since each cell is visited at most once.

Key Points to Mention

  • BFS guarantees shortest path in unweighted graphs
  • Knight moves: 8 possible offsets (e.g., (±2, ±1), (±1, ±2))
  • Visited matrix to avoid cycles and redundant work
  • Blocked cells are obstacles but knight can jump over them
  • Edge cases: start == target, start/target blocked, unreachable target
  • Time and space complexity: O(N^2)

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