How it Works
This Sudoku solver uses dynamic programming (DP) to solve the puzzle. The algorithm works as follows:
- It iterates over each cell in the grid.
- For each empty cell, it tries all possible numbers (1-9) and checks if placing the number is a valid move.
- If placing the number is valid, it recursively attempts to solve the rest of the grid with the current configuration.
- If the grid is solved, it returns true, otherwise, it backtracks and tries the next possible number.
- Dynamic programming helps by memoizing (storing) previously computed results to avoid redundant calculations.