dsa · medium
Valid Sudoku
board is a 9×9 partial Sudoku: digits "1"–"9" or "." for empty. Return whether the filled cells so far obey Sudoku: each row, each column, and each of the nine 3×3 blocks contains no duplicate digit. Empty cells can stay empty; you do not need to decide if the board can be completed.
Arguments
board— 9×9 grid of digits as strings, or "."
Example
A board with no duplicate in any row, column, or 3×3 block → true. Two 8s in the same column → false.
Constraints
board.length == 9 board[i].length == 9 board[i][j] is a digit or "."
Examples
Example 1
Input: [[".",".",".",".","5",".",".","1","."],[".","4",".","3",".",".",".",".","."],[".",".",".",".",".","3",".",".","1"],["8",".",".",".",".",".",".","2","."],[".",".","2",".","7",".",".",".","."],[".","1","5",".",".",".",".",".","."],[".",".",".",".",".","2",".",".","."],[".","2",".","9",".",".",".",".","."],[".",".","4",".",".",".",".",".","."]] Expected: false