标签:false code ali val col har lse cto LIDS
1 class Solution 2 { 3 int row[9][9] = {0};//某一行的某个数 4 int col[9][9] = {0};//某一列的某个数 5 int cell[3][3][9] = {0};//某一个九宫格中的某个数 6 public: 7 bool isValidSudoku(vector<vector<char>>& board) 8 { 9 for(int i = 0;i < 9;i ++) 10 { 11 for(int j = 0;j < 9;j ++) 12 { 13 if(board[i][j] != ‘.‘) 14 { 15 int val = board[i][j] - ‘1‘; 16 if(!row[i][val] && !col[j][val] && !cell[i/3][j/3][val]) //全部为false才可以 17 { 18 row[i][val] = col[j][val] = cell[i/3][j/3][val] = true; 19 } 20 else return false; 21 } 22 } 23 } 24 return true; 25 } 26 };
标签:false code ali val col har lse cto LIDS
原文地址:https://www.cnblogs.com/yuhong1103/p/12513227.html