Simple cpp solution using set

 void Solution::setZeroes(vector<vector<int> > &A) {
// Do not write main() function.
// Do not read input, instead use the arguments to the function.
// Do not print the output, instead return values as specified
// Still have a doubt. Checkout www.interviewbit.com/pages/sample_codes/ for more details
set<int> s1,s2;
for(int i=0;i<A.size();i++){
    for(int j=0;j<A[0].size();j++){
        if(A[i][j]==0){
            s1.insert(i);
            s2.insert(j);
        }
    }
}
for(auto it = s1.begin(); it != s1.end(); it++){
    for(int j=0;j<A[0].size();j++){
        A[*it][j]=0;
    }
}
for(auto it = s2.begin(); it != s2.end(); it++){
    for(int j=0;j<A.size();j++){
        A[j][*it]=0;
    }
}

}

you can use unordered_set to reduce time complexity

Can u explain why will it reduce time complexity?

Click here to start solving coding interview questions