← Amazon Interview Insights

Amazon·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
May 2026

Summary

Amazon SWE interview with a coding round focused on board validation. Pretty algorithmic, no behavioral stuff from what I can tell. The problem had some depth to it once you got past the surface.

Questions Asked (1)

Q1

Given a partially filled 9x9 Sudoku board with digits '1'–'9' and '.' for empty cells, write an algorithm to check whether the current state is valid. No duplicates allowed in any row, column, or 3x3 sub-box. They also asked you to do it in a single pass and explain your data structures and complexity.

Algorithms & Data StructuresTechnical Trade-offs
Author's notes

The single-pass constraint is what makes this interesting.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Clarify that 'valid' means no duplicates among filled cells, then propose a single-pass solution using hash sets (or boolean arrays) for rows, columns, and boxes. Iterate over each cell once, compute the box index, and check for duplicates before inserting.

Pro tip: Emphasize that the board is partially filled, so you only need to validate existing numbers; also mention that you can use bitmasks for O(1) space per row/column/box, which is a strong optimization.

1. Clarify requirements and constraints

Confirm that the board is 9x9, digits are '1'-'9', '.' means empty, and validity only concerns duplicates among filled cells. Ask if the board is guaranteed to be 9x9 and if input is mutable.

2. Choose data structures

Use three sets (or boolean arrays) per row, column, and 3x3 sub-box to track seen digits. Alternatively, use bitmasks (integers) for constant space and faster checks.

3. Single-pass iteration

Loop through each cell (r, c). If the cell is not '.', compute the box index as (r/3)*3 + c/3. Check if the digit already exists in the corresponding row, column, or box set; if yes, return false. Otherwise, add the digit to all three sets.

4. Return result and analyze complexity

After the loop, return true. State that time complexity is O(1) because the board size is fixed (81 cells), but generally O(n^2) for an n x n board. Space complexity is O(1) with fixed-size sets or bitmasks.

5. Discuss trade-offs and optimizations

Mention that using bitmasks reduces space and may improve speed. Also note that early termination on duplicate detection saves time. If asked, explain how to extend to full Sudoku solver.

Key Points to Mention

  • Single-pass iteration over all 81 cells
  • Use of hash sets or boolean arrays for rows, columns, and boxes
  • Box index calculation: (r/3)*3 + c/3
  • Time complexity O(1) for fixed 9x9, space O(1)
  • Early return on duplicate detection
  • Alternative: bitmask representation for constant space and faster checks

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