36. Valid Sudoku*
来源:互联网 发布:ios手绘软件 编辑:程序博客网 时间:2024/06/06 04:23
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.
Reference
class Solution(object): def isValidSudoku(self, board): """ :type board: List[List[str]] :rtype: bool """ used1 = [([0] * 9) for i in range(9)] used2 = [([0] * 9) for i in range(9)] used3 = [([0] * 9) for i in range(9)] for i in range(9): for j in range(9): if board[i][j]!='.': num = int(board[i][j]) - 1 k = i / 3 * 3 + j / 3 if used1[i][num] or used2[j][num] or used3[k][num]: return False used1[i][num] = 1 used2[j][num] = 1 used3[k][num] = 1 return True
0 0
- [LeetCode]36.Valid Sudoku
- 36. Valid Sudoku
- LeetCode --- 36. Valid Sudoku
- LeetCode 36.Valid Sudoku
- [Leetcode] 36. Valid Sudoku
- 36. Valid Sudoku
- 【leetcode】36. Valid Sudoku
- 36. Valid Sudoku
- 36. Valid Sudoku
- [leetcode] 36. Valid Sudoku
- Leetcode 36. Valid Sudoku
- 36. Valid Sudoku
- 36. Valid Sudoku LeetCode
- 36. Valid Sudoku
- 36. Valid Sudoku
- 36. Valid Sudoku
- 36. Valid Sudoku
- 36. Valid Sudoku
- gulp从入门到上树
- 记入职一年
- 收支系统(超超超简版)1.0
- MongoDB Map Reduce
- BZOJ2741分块+字典树
- 36. Valid Sudoku*
- 一个java文件中可不可以有多个类?
- 同时引入多个js发生冲突
- LeetCode 19. Remove Nth Node From End of List
- Gradle实战:执行sql操作hive数据库
- PCB的制作规则
- 第一个GUI程序:“Hello World”
- 内部类
- GET POST方法长度限制