You are given a Sudoku board with 9 rows and 9 columns. Each cell is a digit from "1" to "9", or "." for an empty cell.
The board is valid so far if no digit is repeated in:
- any row,
- any column,
- any of the nine
3 x 3 boxes (the board is cut into these boxes by the thick lines).
Only the filled cells are checked. The board does not have to be solvable. Return true if the board is valid so far, and false if it is not.
Examples
Example 1:
Input: board = [["8",".",".","1",".",".",".",".","2"],[".","2",".",".","7",".",".",".","9"],[".",".","1",".","2",".","8",".","."],["4",".",".",".",".","3",".",".","8"],[".","8",".","2",".","4",".","7","."],["3",".",".","9",".",".",".",".","6"],[".",".","5",".","3",".",".",".","1"],["9",".",".",".","1",".",".","5","."],["2",".","6","5",".",".",".",".","3"]]
Output: true
Explanation: No digit repeats in any row, column or box, so the board is valid so far.
Example 2:
Input: board = [["8",".",".","1",".","8",".",".","2"],[".","2",".",".","7",".",".",".","9"],[".",".","1",".","2",".","8",".","."],["4",".",".",".",".","3",".",".","8"],[".","8",".","2",".","4",".","7","."],["3",".",".","9",".",".",".",".","6"],[".",".","5",".","3",".",".",".","1"],["9",".",".",".","1",".",".","5","."],["2",".","6","5",".",".",".",".","3"]]
Output: false
Explanation: The first row has the digit 8 twice.
Example 3:
Input: board = [["8",".",".","1",".",".",".",".","2"],["1","2",".",".","7",".",".",".","9"],[".",".","1",".","2",".","8",".","."],["4",".",".",".",".","3",".",".","8"],[".","8",".","2",".","4",".","7","."],["3",".",".","9",".",".",".",".","6"],[".",".","5",".","3",".",".",".","1"],["9",".",".",".","1",".",".","5","."],["2",".","6","5",".",".",".",".","3"]]
Output: false
Explanation: Rows and columns are fine, but the top-left box has the digit 1 twice.