Doubt in question
  1. Set Matrix Zeroes

class Solution {
public:
void setZeroes(vector<vector>& matrix) {

    int n=matrix.size();
    int cnt=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(matrix[i][j]==0)
                cnt++;
        }
    }
    cout<<cnt<<endl;
    while(cnt--)
    {
        for(int i=0;i<n;i++)
    {
        for(int j=0;j<n;j++)
        {
            if(matrix[i][j]==0)
            {
                for(int x=0;x<n;x++)
                {
                    matrix[i][x]=0;
                    matrix[x][j]=0;
                }
            }
        }
        }
        
    }
    
    
}

};

Can someone tell me as to where am i going wrong?

Comments (0)