NEAT C++ Solution Using set and Fill functions

void Solution::setZeroes(vector<vector > &A) {
int n = A.size();
int m = A[0].size();
set R,C;
for(int i = 0;i<n;i++)
{
for(int j = 0;j<A[0].size();j++)
{
if(A[i][j] == 0)
{
R.insert(i);
C.insert(j);
}
}
}

for(auto X : R)
    fill(A[X].begin(),A[X].end(),0);

for(auto X:C)
{
for(int i = 0;i<n;i++)
{
A[i][X] = 0;
}
}
return;
}
indent preformatted text by 4 spaces

Click here to start solving coding interview questions