Using 3 hashMap java


#1
public int isValidSudoku(final List<String> A) {
    HashMap<Integer, HashSet<Character>> row = new HashMap ();
    HashMap<Integer, HashSet<Character>> col = new HashMap ();
    HashMap<Integer, HashSet<Character>> bpx = new HashMap ();
    
    for (int i = 0; i<A.size(); i++){
        for (int j = 0; j<A.get(i).length(); j++){
            Character charAt = A.get(i).charAt(j);
            if(charAt == '.'){
                continue;
            }
            if((row.get(i) != null && row.get(i).contains(charAt)) ||
            (col.get(j) != null && col.get(j).contains(charAt)) ||
            (bpx.get((i/3)*3 + j/3) != null && bpx.get((i/3)*3 + j/3).contains(charAt))){
                return 0;
            } else {
                if (row.get(i) == null){
                    row.put (i, new HashSet<Character>());
                }
                if (col.get(j) == null){
                    col.put (j, new HashSet<Character>());
                }
                if (bpx.get((i/3)*3 + j/3) == null){
                    bpx.put ((i/3)*3 + j/3, new HashSet<Character>());
                }
                row.get(i).add(charAt);
                col.get(j).add(charAt);
                bpx.get((i/3)*3 + j/3).add(charAt);
            }
        }
    }
    return 1;
}

#2

why i/3*3+j/3?? I don’t get it.


#3

i/33+j/3 to get small square number (ex 33 grid number for 9*9 square)