leetcode之valid sudoku
来源:互联网 发布:大数据培训班多少钱 编辑:程序博客网 时间:2024/06/09 12:35
题目:
Determine if a Sudoku is valid
解答:
就是分别对行,列,宫格进行出现的数字的判断即可
class Solution {public: bool isValidSudoku(vector<vector<char>>& board) { memset(cols,0,sizeof(cols)); memset(rows,0,sizeof(rows)); memset(grid,0,sizeof(grid)); for(int i = 0;i < 9;++i) { for(int j = 0;j < 9;++j) { if(board[i][j] == '.') continue; int t = board[i][j] - '0'; if(cols[j][t] == true) return false; cols[j][t] = true; if(rows[i][t] == true) return false; rows[i][t] = true; if(grid[i/3][j/3][t] == true) return false; grid[i/3][j/3][t] = true; } } return true; }private: bool cols[9][10]; bool rows[9][10]; bool grid[3][3][10];};
0 0
- 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 && 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
- Git和Repo扫盲——如何取得Android源代码
- 【C++】在 Visual Studio 调试器中指定符号 (.pdb) 和源文件(转载自RSS翻译)
- 【技巧】对拍
- 开启CSDN博客第一天
- Baby Ming and Weight lifting(BestCoder)
- leetcode之valid sudoku
- C语言顺序访问文件6个方法
- nyoj456 邮票分你一半(01背包)
- UI组件之TimePiker
- PAT 1044. Shopping in Mars
- leetcode之Reverse Bits
- Baby Ming and phone number(BC)
- struts2拦截器
- Spring MVC 生成EXCEL