37 Sudoku Solver

1. Question

Write a program to solve a Sudoku puzzle by filling the empty cells.

Empty cells are indicated by the character'.'.

You may assume that there will be only one unique solution.

A sudoku puzzle...

...and its solution numbers marked in red.

2. Implementation

(1) Backtracking

3. Time & Space Complexity

Backtracking: 时间复杂度O(9^n),n是board为空格的个数, 空间复杂度O(n), 递归的深度最多为n

Last updated

Was this helpful?