Problem
You get a 9 x 9 Sudoku board board. Each cell contains a digit from "1" to "9", or "." for an empty cell.
Return true if the filled cells obey the three rules below. Return false if a filled cell breaks a rule.
Each row contains each digit at most one time. Each column contains each digit at most one time. Each of the nine 3 x 3 boxes contains each digit at most one time. The boxes do not overlap. For example, rows 0 to 2 and columns 0 to 2 make the top left box.
Check only the filled cells. A board can obey the rules and still have no full solution. You do not need to find a solution.
Example 1
- Input:
- board = [[".","2",".",".",".","8",".",".","."],["6",".",".","1",".",".",".","4","."],[".",".","9",".",".",".","7",".","."],[".","5",".",".","3",".",".",".","8"],[".",".",".","9",".","2",".",".","."],["4",".",".",".","6",".",".","1","."],[".",".","3",".",".",".","2",".","."],[".","9",".",".",".","4",".",".","6"],[".",".",".","7",".",".",".","3","."]]
- Output:
- true
- Explanation:
- No row, column or 3 x 3 box contains a digit two times.
Example 2
- Input:
- board = [[".","2",".",".",".","8",".",".","."],["6",".",".","1",".",".",".","4","."],["2",".","9",".",".",".","7",".","."],[".","5",".",".","3",".",".",".","8"],[".",".",".","9",".","2",".",".","."],["4",".",".",".","6",".",".","1","."],[".",".","3",".",".",".","2",".","."],[".","9",".",".",".","4",".",".","6"],[".",".",".","7",".",".",".","3","."]]
- Output:
- false
- Explanation:
- Row 2 and column 0 obey the rules. But the top left 3 x 3 box contains the digit 2 two times.
Constraints
- board.length == 9
- board[i].length == 9
- board[i][j] is a digit from "1" to "9" or ".".
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
- Design Excel Sum Formula
Coding · Array · Design · Graph Theory
- Design Spreadsheet
Coding · Array · Design · Hash Table
- Match Alphanumerical Pattern in Matrix I
Coding · Array · Hash Table · Matrix
- Number of Distinct Islands
Coding · Array · Breadth-First Search · Depth-First Search
Sources · 2 references
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 3 records
Amazon
Leetcode 36. Valid Sudoku
Reported May 18, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceCisco
Leetcode 36. Valid Sudoku
Reported Apr 1, 2026 · 1 source report
SENIOR
Source snapshot: Nov 12, 2026
View sourceMicrosoft
Leetcode 36. Valid Sudoku
Reported Apr 26, 2026 · 1 source report
MID_LEVEL
Source snapshot: Nov 12, 2026
View source
LeetCode company tags · 2 records
Amazon
Valid Sudoku
Reported date not specified · Source window: 30d