LeetCode----36. Valid Sudoku(有效数读)
来源:互联网 发布:mac远程桌面连接软件 编辑:程序博客网 时间:2024/06/09 23:35
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.
//分三次判断
public class Solution { public boolean isValidSudoku(char[][] board) { boolean[] nine=new boolean[9]; for(int i=0;i<9;i++){ Arrays.fill(nine, false); for(int j=0;j<9;j++){ if(!valid(nine,board[i][j])){return false;} } } for(int i=0;i<9;i++){ Arrays.fill(nine, false); for(int j=0;j<9;j++){ if(!valid(nine,board[j][i])){return false;} } } for(int i=0;i<9;i+=3){ for(int j=0;j<9;j+=3){ Arrays.fill(nine, false); for(int k=0;k<9;k++){ if(!valid(nine,board[i+k/3][j+k%3])){return false;} } } } return true; } public boolean valid(boolean []arr,char target){ if(target=='.'){return true;} int num=target-'0'; if(num<1||num>9||arr[num-1]){return false;} arr[num-1]=true; return true; }}
0 0
- LeetCode----36. Valid Sudoku(有效数读)
- leetcode 36. Valid Sudoku 数独有效
- leetcode 36. Valid Sudoku-有效数独|哈希表
- LeetCode-36. Valid Sudoku (JAVA)(有效数独)
- LeetCode:36. Valid Sudoku,数独是否有效 :
- 有效数独 Valid Sudoku
- Valid Sudoku 检查数独是否有效 @LeetCode
- [leetcode]Valid Sudoku(判断有效数独 C语言实现)
- LeetCode 36 Valid Sudoku(有效数独)
- leetCode 36.Valid Sudoku(有效的数独) 解题思路和方法
- leetcode 37. Sudoku Solver 36. Valid Sudoku 数独问题
- Valid Sudoku 有效的数独
- [LeetCode]36.Valid Sudoku
- LeetCode --- 36. Valid Sudoku
- LeetCode 36.Valid Sudoku
- [Leetcode] 36. Valid Sudoku
- 【leetcode】36. Valid Sudoku
- [leetcode] 36. Valid Sudoku
- CodeForces-719E Sasha and Array(线段树+矩阵快速幂)
- DKMS介绍
- SqlHelper
- POJ1742 多重背包
- MVC、MVP、MVVM
- LeetCode----36. Valid Sudoku(有效数读)
- Java反射三种方式的效率对比
- js实现继承几种方法(未完待续)
- Android 6.0 - 动态权限管理的解决方案
- android 文件读取(assets)
- centos 开启DHCP服务
- H.264 Profile、Level、Encoder三张简图
- Jquery 处理JSON数据(1)
- Java静态方法,静态变量,初始化顺序