Untitled
unknown
plain_text
7 months ago
581 B
0
Indexable
Never
class Solution { public: bool isValidSudoku(vector<vector<char>>& board) { vector<vector<int>> row(9,vector<int>(9,0)), col(9,vector<int>(9,0)), grid(9,vector<int>(9,0)); for(int i=0;i<9;i++){ for(int j=0;j<9;j++){ if(board[i][j]!='.'){ int num=board[i][j]-'1'; int k= i/3*3 +j/3; if(row[i][num] || col[num][j] || grid[k][num]) return false; row[i][num]=col[num][j]=grid[k][num]=1; } } } return true; } };
Leave a Comment