Valid Sudoku
Determine whether a partially filled 9x9 Sudoku board is valid. Only the filled cells (digits '1'-'9') need to be checked: no digit may repeat within any row, any column, or any of the nine 3x3 sub-boxes. Empty cells are marked '.' and the board need not be solvable.
Open official problem prompt ↗Confirm that the currently placed digits break none of Sudoku's three no-repeat rules, without needing to solve the puzzle.
Like a proctor checking a seating chart: no two people with the same ID may share a row, a column, or a table cluster. You keep a checklist per row, per column, and per cluster and flag the first collision.
- Input
- board = [["5","3",".",".","7",".",".",".","."],["6",".",".","1","9","5",".",".","."],[".","9","8",".",".",".",".","6","."],["8",".",".",".","6",".",".",".","3"],["4",".",".","8",".","3",".",".","1"],["7",".",".",".","2",".",".",".","6"],[".","6",".",".",".",".","2","8","."],[".",".",".","4","1","9",".",".","5"],[".",".",".",".","8",".",".","7","9"]]
- Output
- true
- Why
- No digit repeats in any row, column, or 3x3 box, so the board is valid.
board.length == 9board[i].length == 9board[i][j] is a digit '1'-'9' or '.'Only filled cells are validated