题目链接
https://leetcode.com/problems/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.
题目翻译
判断一个数独是否是有效的。判断依据:Sudoku Puzzles - The Rules。
一个数独的表格可以是只填写了一部分,空的格子用点号’.’填充,比如,下图是一个有效的部分数独:
注意:一个有效的数独板(部分填充的)不一定可解。你只需要验证被填充的部分即可。
思路方法
首先,简单说一下规则:数独的每一行、每一列、9个九宫格里的数字只能是0-9,且不能重复。
思路一
最直观的思路,三个规则全部检查一遍即可。
代码
class Solution(object):
def isValidSudoku(self, board):
"