Simple cpp solution using hashmap or unorderedmap

  void Solution::setZeroes(vector<vector<int> > &A) {

    int n= A.size();
    int m = A[0].size();
    unordered_set<int>col;
    unordered_set<int>row;
    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            if (A[i][j] == 0){
                row.insert(i);
                col.insert(j);
            }
        }
    }

    for (int i=0;i<n;i++){
        for (int j=0;j<m;j++){
            if (row.find(i) != row.end() || col.find(j) != col.end()){
                A[i][j] = 0;
            }
        }
}
}
Click here to start solving coding interview questions