LeetCode 36. Valid Sudoku

Determine if a Sudoku is valid, according to: Sudoku Puzzles - The Rules.
The Sudoku board could be partially filled, where empty cells are filled with the character '.'

LeetCode 36. Valid Sudoku_第1张图片

A partially filled sudoku which is valid.

题意:判断这个数独是不是一个合法的数据,也就是说,一行,一列,还有一块,都只能是从1-9不能重复。

Note:
A valid Sudoku board (partially filled) is not necessarily solvable. Only the filled cells need to be validated.

public boolean isValidSudoku(char[][] board) {  
        List> rl = new ArrayList>();  
        List> cl = new ArrayList>();  
        List> sl = new ArrayList>();  
          
        for(int i=0; i<9; i++) {  
            rl.add(new HashSet());  
            cl.add(new HashSet());  
            sl.add(new HashSet());  
        }  
        int n = board.length;  
        for(int i=0; i

你可能感兴趣的:(LeetCode 36. Valid Sudoku)