@@ -0,0 +1,2359 @@
+package leetcode;%0A%0Aimport java.util.HashMap;%0Aimport java.util.HashSet;%0Aimport java.util.Map;%0Aimport java.util.Set;%0A%0A/**%0A * https://oj.leetcode.com/problems/valid-sudoku/%0A */%0Apublic class Problem36 %7B%0A    public boolean isValidSudoku(char%5B%5D%5B%5D board) %7B%0A        boolean all = isValidSudokuFullGrid(board);%0A        if (!all) %7B%0A            return false;%0A        %7D%0A        for (int i = 0; i %3C board.length; i += 3) %7B%0A            for (int j = 0; j %3C board.length; j += 3) %7B%0A                if (!isValidSudokuSubGrid(board, i, i+3, j, j+3)) %7B%0A                    return false;%0A                %7D%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%0A    private boolean isValidSudokuFullGrid(char%5B%5D%5B%5D board) %7B%0A        Map%3CInteger, Set%3CCharacter%3E%3E rowMap = new HashMap%3C%3E();%0A        Map%3CInteger, Set%3CCharacter%3E%3E colMap = new HashMap%3C%3E();%0A        for (int i = 0; i %3C board.length; i++) %7B%0A            for (int j = 0; j %3C board%5Bi%5D.length; j++) %7B%0A                char c = board%5Bi%5D%5Bj%5D;%0A                if (c == '.') %7B%0A                    continue;%0A                %7D%0A                if (!rowMap.containsKey(i)) %7B%0A                    rowMap.put(i, new HashSet%3CCharacter%3E());%0A                %7D%0A                if (!colMap.containsKey(j)) %7B%0A                    colMap.put(j, new HashSet%3CCharacter%3E());%0A                %7D%0A                Set%3CCharacter%3E rowSet = rowMap.get(i);%0A                if (rowSet.contains(c)) %7B%0A                    return false;%0A                %7D else %7B%0A                    rowSet.add(c);%0A                %7D%0A                Set%3CCharacter%3E colSet = colMap.get(j);%0A                if (colSet.contains(c)) %7B%0A                    return false;%0A                %7D else %7B%0A                    colSet.add(c);%0A                %7D%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A    %0A    private boolean isValidSudokuSubGrid(char%5B%5D%5B%5D board, int startRow, int endRow,%0A        int startCol, int endCol) %7B%0A        Set%3CCharacter%3E set = new HashSet%3C%3E();%0A        for (int i = startRow; i %3C endRow; i++) %7B%0A            for (int j = startCol; j %3C endCol; j++) %7B%0A                char c = board%5Bi%5D%5Bj%5D;%0A                if (c == '.') %7B%0A                    continue;%0A                %7D%0A                if (set.contains(c)) %7B%0A                    return false;%0A                %7D else %7B%0A                    set.add(c);%0A                %7D%0A            %7D%0A        %7D%0A        return true;%0A    %7D%0A%7D%0A

Solve problem 36