Back to Practice
#0294
Valid Sudoku Board
MediumDSA28 min20 XP
Problem
Given a 9x9 board containing digits "1" through "9" and "." for empty cells, return True if no row, column, or 3x3 box contains a repeated digit.
Why This Matters
Sudoku validation is a clean example of mapping 2D coordinates to constraint groups.
Function Signature
def is_valid_sudoku(board):
Examples
Example 1
Inputboard with no repeated row, column, or box digits
OutputTrue
Empty cells are ignored; only repeated filled digits matter.
Constraints
- Return the exact requested value.
- Handle edge cases cleanly.
- Use the intended DSA pattern when brute force would scale poorly.
CodePython
Visible browser tests run here when available.
Testcases2 visible / 3 hidden categories
Valid partial board
Inputclassic valid board
ExpectedTrue
No constraint group repeats a digit.
Repeated row digit
Inputduplicate 5 in row 0
ExpectedFalse
Two 5s in the same row make the board invalid.
Hidden Test Categories
duplicate in columnduplicate in 3x3 boxmostly empty board