public int[][] clearZero(int[][] mat, int n) {
// write code here
int[][] result = new int[n][n];
int[] resulttmp = new int[n];
int[] h= new int[n];
List<Integer> hlist = new ArrayList<>();
List<Integer> llist = new ArrayList<>();
for (int j=0;j<n;j++){
int[] tmp = mat[j];
for (int i=0;i<n;i++){
int count =tmp[i];
if(count==0){
hlist.add(j);
llist.add(i);
}
}
}
for (int x=0;x<n;x++){
int[] tmp = mat[x];
for (int y=0;y<n;y++){
if(hlist.contains(x) ||llist.contains(y)){
resulttmp[y] = 0;
}else {
resulttmp[y] = tmp[y];
}
}
result[x] = resulttmp;
resulttmp = new int[n];
}
return result;
}