LEETCODE-- Valid Sudoku
来源:互联网 发布:网络机房运维方案 编辑:程序博客网 时间:2024/05/29 18:30
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.
Subscribe to see which companies asked this question
class Solution {public: bool check(int *array, int val){ if(array[val] >= 1){ return false; } else{ array[val]++; return true; } } bool isValidSudoku(vector<vector<char>>& board) { int row[10] = {0}; int column[10][10] = {0}; int subboxes[10][10] = {0}; for(int i = 0; i < 9; i++){ memset( row, 0, sizeof(row)); for(int j = 0; j < 9; j++){ if(board[i][j] != '.'){ int num = board[i][j] - '0'; if( check(row, num) && check(column[j],num) && check(subboxes[i/3*3+j/3],num)){ //Do nothing; } else{ return false; } } } } 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)
- HYSBZ/BZOJ 1034 [ZJOI2008] 泡泡堂BNB - 贪心
- 如何在本地环境配置github
- 图解Android事件传递之View篇
- C++扫雷
- 白书练习 二叉树的重构
- LEETCODE-- Valid Sudoku
- 每天一点点----项目中關鍵字 “ collectgarbage”
- C++ previous declaration of...with 'C++' linkage
- C++/MFC修行之路(3) MFC中各个类的互相访问/取指针
- HDU 1004.Let the Balloon Rise【找出出现次数最多的字符串】
- js中cookie的使用
- 互联网电视
- spring4+hessian实例^_^
- 不无聊的序列(Non-boring sequences,Bzoj4059,CERC2012)