Determine if a&nbsp;9 x 9 Sudoku board&nbsp;is valid.&nbsp;Only the filled cells need to be validated&nbsp;according to the following rules:


	Each row&nbsp;must contain the&nbsp;digits&nbsp;1-9 without repetition.
	Each column must contain the digits&nbsp;1-9&nbsp;without repetition.
	Each of the nine&nbsp;3 x 3 sub-boxes of the grid must contain the digits&nbsp;1-9&nbsp;without repetition.


Note:


	A Sudoku board (partially filled) could be valid but is not necessarily solvable.
	Only the filled cells need to be validated according to the mentioned&nbsp;rules.


&nbsp;
Example 1:

Input: board = 
[["5","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,["8",".",".",".","6",".",".",".","3"]
,["4",".",".","8",".","3",".",".","1"]
,["7",".",".",".","2",".",".",".","6"]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
Output: true


Example 2:

Input: board = 
[["8","3",".",".","7",".",".",".","."]
,["6",".",".","1","9","5",".",".","."]
,[".","9","8",".",".",".",".","6","."]
,["8",".",".",".","6",".",".",".","3"]
,["4",".",".","8",".","3",".",".","1"]
,["7",".",".",".","2",".",".",".","6"]
,[".","6",".",".",".",".","2","8","."]
,[".",".",".","4","1","9",".",".","5"]
,[".",".",".",".","8",".",".","7","9"]]
Output: false
Explanation: Same as Example 1, except with the 5 in the top left corner being modified to 8. Since there are two 8's in the top left 3x3 sub-box, it is invalid.


&nbsp;
Constraints:


	board.length == 9
	board[i].length == 9
	board[i][j] is a digit 1-9 or '.'.


class Solution:
    def isValidSudoku(self, board: List[List[str]]) -> bool:

        hrow = {}
        hcol = {}
        hbox = defaultdict(list)

        #CHECK FOR DUPLICATES ROWWISE
        for i in range(9):
            for j in range(9):

                #JUST THAT THE DUPLICATE SHOULDNT BE ","
                if board[i][j] != '.':

                    if board[i][j] not in hrow:
                        hrow[board[i][j]] = 1

                    else:
                        return False

            #CLEAR HASHMAP FOR THIS ROW
            hrow.clear()
        print("TRUE1")
        #CHECK FOR DUPLICATES COLUMNWISE

        for i in range(9):
            for j in range(9):

                #JUST THAT THE DUPLICATE SHOULDNT BE ","
                if board[j][i] != '.':

                    if board[j][i] not in hcol:
                        hcol[board[j][i]] = 1

                    else:
                        return False

        #CLEAR HASHMAP FOR THIS COL

            hcol.clear()

        print('TRUE2')

        #CHECK DUPLICATE IN BOX, THIS IS WHERE KEY DESIGN SKILLS COME INTO PLAY, FOR SUDOKU YOU COMBINE ROW INDICES AND COL INDICES

        for i in range(9):
            for j in range(9):

                i_3 = i //3
                j_3 = j//3

                # print(hbox)
                if board[i][j] != '.':

                #CHECK ELEMENT OF ORIGINAL INDICE present in key i_3 , j_3
                    if board[i][j] not in hbox[i_3 , j_3]:
# #CHECKED IN NEW KEY
                        hbox[i_3 ,j_3 ]= hbox[i_3 ,j_3 ] + [board[i][j]]

                    else:
                        return False

        return True
    for(int i=0; i<9; i++){
         for(int j=0; j<9; j++){
          if(board[i][j] != '.'){ 
              char currentVal = board[i][j];
               if(!(seen.add(currentVal + "found in row "+ i)) ||
                  !(seen.add(currentVal + "found in column "+ j) ) ||
                  !(seen.add(currentVal + "found in sub box "+ i/3 + "-"+ j/3)))
                   return false;
          }
      
       } 
    
    }
    return true;
}
class Solution {
public:
    bool isValidSudoku(vector<vector<char>>& board) {
        
        int n = board.size();
        
        for(int i=0;i<n;i++){
            unordered_map<char,int>m;
            for(int j=0;j<board[i].size();j++){
                if(board[i][j]=='.'){
                    continue;
                }
                if(m.find(board[i][j])!=m.end()){
                    return false;
                }
                else{
                    m[board[i][j]]++;
                }
            }
        }
        
        for(int i=0;i<n;i++){
            unordered_map<char,int>m;
            for(int j=0;j<n;j++){
                
                if(board[j][i]=='.'){
                    continue;
                }
                
                if(m.find(board[j][i])!=m.end()){
                    return false;
                }
                else{
                    m[board[j][i]]++;
                }
            }
        }
        
        for(int i=0;i<n;i+=3){
            for(int j=0;j<n;j+=3){
                
                unordered_map<char,int>m;
                for(int k=i;k<=i+2;k++){
                    for(int p=j;p<=j+2;p++){
                        
                        if(board[k][p]=='.'){
                            continue;
                        }
                        
                        if(m.find(board[k][p])!=m.end()){
                            return false;
                        }
                        else{
                            m[board[k][p]]++;
                        }
                    }
                }
            }
        }
        
        return true;
    }
};
/**
 * @param {character[][]} board
 * @return {boolean}
 */
var isValidSudoku = function(board) {
    let rowMap = new Map();
    let colMap = new Map();
    let square = new Map();
    for(let i=0; i<board.length; i++) {
        for(let j=0; j<board[0].length; j++) {
            if(board[i][j] === '.') continue;
            if(!rowMap.has(i)) rowMap.set(i, new Set());
            if(!colMap.has(j)) colMap.set(j, new Set());
            let squareKey = Math.floor(i/3) + '#' + Math.floor(j/3);
            if(!square.has(squareKey)) square.set(squareKey, new Set());
            let rowSet = rowMap.get(i);
            let colSet = colMap.get(j);
            let squareSet = square.get(squareKey);
            if(rowSet.has(board[i][j]) || colSet.has(board[i][j]) || squareSet.has(board[i][j])) return false;
            rowSet.add(board[i][j]);
            colSet.add(board[i][j]);
            squareSet.add(board[i][j]);
            rowMap.set(i, rowSet);
            colMap.set(j, colSet);
            square.set(squareKey, squareSet);
        }
    }
    return true;
};
Valid Sudoku