Java Simple to Understand Solution


#1
public class Solution {
    public void setZeroes(ArrayList<ArrayList<Integer>> a) {
        HashSet<Integer> rowSet = new HashSet<>();
        HashSet<Integer> colSet = new HashSet<>();
        for(int row = 0; row < a.size(); row++) {
            for(int col = 0; col < a.get(0).size(); col++) {
                if(a.get(row).get(col) == 0) {
                    rowSet.add(row);
                    colSet.add(col);
                }
            }
        }
        for(int row = 0; row < a.size(); row++) {
            for(int col = 0; col < a.get(0).size(); col++) {
                if(rowSet.contains(row) || colSet.contains(col)) {
                    a.get(row).set(col, 0);
                }
            }
        }
    }
}

#2

Really a simple solution.Thanks.