leetcode 36 有效的数独
有效的数独 https://leetcode-cn.com/problems/valid-sudoku/ 代码 public static boolean isValidSudoku(char[][] board) { List<Set<Integer>> rowList = new ArrayList<>(9); List<Set<Integer>> colList = new ArrayList<>(9); List<Set<Integer>> blockList = new ArrayList<>(9); for (int i = 0; i < 9; i++) { rowList.add(new HashSet<>(9)); colList.add(new HashSet<>(9)); blockList.add(new HashSet<>(9)); } for (int i = 0; i < board.length; i++) { for (int j = 0; j < board[0].length; j++) { char num = board[i][j]; Set<Integer> rowSet = rowList.get(i); Set<Integer> colSet = colList.get(j); int rowNum = (i / 3) * 3 + j