Backtracking
LC #37Hard
Sudoku Solver
Backtracking
AmazonGoogleMetaProblem
Solve a Sudoku puzzle by filling in the empty cells.
backtrackingmatrix
Constraints
- ›board.length == 9, board[i].length == 9
- ›board[i][j] is a digit 1–9 or '.'
- ›Exactly one valid solution guaranteed
Example
Input
9×9 board with some cells filled (see LeetCode)Output
Board with all cells filled correctlyWhy
Each row, column, and 3×3 sub-box must contain 1–9 exactly once