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.
解法1: DFS, O(9^N)
N是空格子的总数
就是一个比较直接的dfs的题。对于每一个空格子尝试从1到9,然后检查是否是valid,如果是则继续,如果不是就填回原来的数字。
|
|