Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- knaul853
- //https://stackoverflow.com/a/10163885/9959901
- **/
- class Solution {
- public:
- bool isValidSudoku(vector<vector<char>>& board) {
- unordered_set<char> row[9],col[9],square[3][3];
- for(int i=0;i<9;i++){
- for(int j=0;j<9;j++){
- char ch = board[i][j];
- if(ch !='.'){
- if(!row[i].insert(ch).second || !col[j].insert(ch).second
- || !square[i/3][j/3].insert(ch).second) return false;
- }
- }
- }
- return true;
- }
- };
Add Comment
Please, Sign In to add comment