My solution is kind of hackish - accpeted. So, I want to know if there is a better constant space solution?

I traverse the matrix and if I find a zero, I replace all the elements, except the 0 elements, of the corresponding row and column with -1. Finally I make all the -1 to 0.

This algorithm would fail if the matrix has -1s.

```
void setZeroes(vector<vector<int> > &matrix) {
int i,j,k,m,n;
m = matrix.size();
n = matrix[0].size();
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(matrix[i][j]==0)
{
for(k=0;k<n;k++)
if(matrix[i][k]!=0)
matrix[i][k] = -1;
for(k=0;k<m;k++)
if(matrix[k][j]!=0)
matrix[k][j] = -1;
}
for(i=0;i<m;i++)
for(j=0;j<n;j++)
if(matrix[i][j]==-1)
matrix[i][j]=0;
}
```