# leetcode 36. Valid Sudoku || 37. Sudoku Solver

• 36. Valid Sudoku
• 37. Sudoku Solver

### 36. Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles – The Rules.

The Sudoku board could be partially filled, where empty cells are filled with the character `'.'`.

A partially filled sudoku which is valid.

Note:
A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated.

C++

C++

python

### 37. Sudoku Solver

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.

C++

Python

• 36. Valid Sudoku
• 37. Sudoku Solver

### 2 thoughts on “leetcode 36. Valid Sudoku || 37. Sudoku Solver”

1. ez says:

LN 10: if (board[x / 3 * 3 + i][y / 3 * 3 + j] == board[x][y] && x != x / 3 * 3 + i &&y != y / 3 * 3 + j)

这里是不是应该改成
x != x / 3 * 3 + i || y != y / 3 * 3 + j

否则就会变成对角线啦~ 请多多指教~

• if (board[x / 3 * 3 + i][y / 3 * 3 + j] == board[x][y] && x != x / 3 * 3 + i &&y != y / 3 * 3 + j) 这个的意思是说x和y的和待判定的点不一样，而不是对角线的意思。
是为了防止这种情况的发生：board[x / 3 * 3 + i][y / 3 * 3 + j] == board[x / 3 * 3 + i][y / 3 * 3 + j]