LeetCode Valid Sudoku
来源:互联网 发布:沈阳云易惠网络 编辑:程序博客网 时间:2024/06/11 14:03
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.
思路:判断同一行,列,格子时候满足不同的数,数组判重就行了
class Solution {public: bool isValidSudoku(vector<vector<char> > &board) { int rows[10][10], cols[10][10], block[10][10]; memset(rows, 0, sizeof(rows)); memset(cols, 0, sizeof(cols)); memset(block, 0, sizeof(block)); for (int i = 0; i < 9; i++) for (int j = 0; j < 9; j++) { if (board[i][j] == '.') continue; int cur = board[i][j] - '0'; if (rows[i][cur] || cols[j][cur] || block[i/3*3+j/3][cur]) return false; rows[i][cur] = cols[j][cur] = block[i/3*3+j/3][cur] = 1; } return true; }};
0 0
- 【LeetCode】Valid Sudoku && Sudoku Solver
- [Leetcode]Sudoku Solver&&Valid Sudoku
- leetcode Valid Sudoku & Sudoku Solver
- LeetCode : Valid Sudoku
- [LeetCode]Valid Sudoku
- [leetcode] Valid Sudoku
- LeetCode-Valid Sudoku
- LeetCode Valid Sudoku
- LeetCode - Valid Sudoku
- LeetCode:Valid Sudoku
- leetcode-036:Valid Sudoku
- Leetcode: Valid Sudoku
- LeetCode题解:Valid Sudoku
- 【LeetCode】 Valid Sudoku
- Leetcode Valid Sudoku
- LeetCode | Valid Sudoku
- LeetCode Valid Sudoku
- [Leetcode] Valid Sudoku (Java)
- 文本和代码文件助手软件
- hdu 5178想法题
- python 一个简单的、迅速生成和执行循环的辅助脚本
- node+npm安装好之后,express 提示不是内部或外部命令
- 阿里巴巴技术实习生面试,c++方向
- LeetCode Valid Sudoku
- 高僧斗法
- SpringMVC快速上手案例
- 仿微信6.0主界面实现
- Ultra Edit 自动备份设置的取消
- 什么是类
- Linux下 Mysql 互为主从
- android 从url下载视频并用videoView播放
- 定义成员函数