Valid Sudoku
Given a partially filled 9 x 9 Sudoku board, determine whether the currently placed digits are valid. The board uses the strings "1"–"9" for digits and "." for empty cells.
The board is valid when:
- each row contains no repeated digit,
- each column contains no repeated digit,
- each of the nine 3 x 3 sub-boxes contains no repeated digit.
Only the filled cells are checked — the board does **not** need to be solvable. Return true if valid, false otherwise.
Example cases
- valid boardin board =53..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79out trueNo row, column, or 3x3 box repeats a digit.
- duplicate in column and boxin board =83..7....6..195....98....6.8...6...34..8.3..17...2...6.6....28....419..5....8..79out falseTwo 8s share the top-left column (and box) — the first column has 8 at rows 0 and 3.
Constraints
- board.length == 9
- board[i].length == 9
- board[i][j] is a digit "1"-"9" or ".".
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"]]