Check whether a partially filled Sudoku board satisfies all Sudoku rules.
You are given a partially filled Sudoku board. Some cells contain digits from 1 to 9, and empty cells are marked with '.'.
Determine whether the current board configuration is valid.
A valid Sudoku board must satisfy all of the following rules:
1 to 9.1 to 9.1 to 9.Only the filled cells need to be checked; the board does not need to be solvable.
1 to 9 or '.' for empty.true if the board is valid according to Sudoku rules.false.'.' should be ignored.1 through 9.Example 1
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
Explanation
No row, column, or 3x3 sub-box contains duplicate filled digits.
Example 2
Input
board = [ ["8","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
false
Explanation
The digit 8 appears twice in the first column, so the board is invalid.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.