class Solution {
private:
void make_zero(vector<vector<int> >& matrix,vector<pair<int,int>>v,int n,int m)
{
for(auto i:v)
{
for(int j=0;j<n;j++)
{
matrix[i.first][j]=0;
}
for(int j=0;j<m;j++)
{
matrix[j][i.second]=0;
}
}
}
public:
void setZeroes(vector<vector<int>>& matrix) {
int n=matrix.size();
int m=matrix[0].size();
vector<pair<int,int>>v;
for(int i=0;i<n;i++)
{
for(int j=0;j<m;j++)
{
if(matrix[i][j]==0)
{
v.push_back({i,j});
}
}
}
make_zero(matrix,v,n,m);
}
};
>Solution :
n and m are swapped around in make_zero(), you confused the row and column dimensions.