......short and easy c++ solution


#1
bool isValid(vector<vector<char>> &A, int row, int col, char t){
    for(int j=0; j<9; j++){
        if(A[row][j]==t) return false;
    }    
    for(int i=0; i<9; i++){
        if(A[i][col]==t) return false;
    }
    int rowB=(row/3)*3;
    int colB=(col/3)*3;
    for(int i=rowB; i<rowB+3; i++){
        for(int j=colB; j<colB+3; j++){
            if(A[i][j]==t) return false;
        }
    }
    return true;
}

bool solve(vector<vector<char>> &A, int row, int col){
    if(row==9) return true;
    if(col==9) return solve(A, row+1, 0);
    if(A[row][col]!='.') return solve(A, row, col+1);
    for(int i=1; i<=9; i++){
        char t = '0'+i;
        if(isValid(A, row, col, t)){
            A[row][col]=t;
            if(solve(A, row, col+1)) return true;
            else A[row][col]='.';
        }
    }
    return false;
}

void Solution::solveSudoku(vector<vector<char>> &A) {
    bool t = solve(A, 0, 0);
}