Brute Force Worked Xd


#1
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

int row=A.size(),col=A[0].size(),i,j;
bool a[row],b[col];
for(i=0;i<row;i++)a[i]=0;
for(i=0;i<col;i++)b[i]=0;
for(i=0;i<row;i++){
    for(j=0;j<col;j++)if(A[i][j]==0){
        a[i]=1;
        b[j]=1;
    }
}
for(i=0;i<row;i++){
    if(a[i]==1)for(j=0;j<col;j++)A[i][j]=0;
}
for(j=0;j<col;j++){
    if(b[j]==1)for(i=0;i<row;i++)A[i][j]=0;
}

}