```
public class Solution {
public void setZeroes(int[][] matrix) {
HashSet<Integer> row = new HashSet<Integer>();
HashSet<Integer> col = new HashSet<Integer>();
for(int i = 0; i < matrix.length; i++){
for(int j = 0; j < matrix[0].length; j++){
if(matrix[i][j] == 0){
row.add(i);
col.add(j);
}
}
}
for(int i = 0; i < matrix.length; i++){
for(int j = 0; j < matrix[0].length; j++){
if(row.contains(i) || col.contains(j)){
matrix[i][j] = 0;
}
}
}
}
```

}

I am sharing my solution because I thought this could be easier to understand. But I am not sure if using hashset means extra space? Can anyone tell me how to improve the code or how to solve this question by using "constant space"? Thanks in advance.