Sharing ACTUAL readable solution


  • 0
    H
    def valid_sudoku(self, board):
     row, col, square = set(), set(), set()
            for j in range(9):
                for i in range(9):
                    if board[j][i] == '.':
                        continue
                    num = board[j][i]
                    curr_row = (i, num)
                    curr_col = (j, num)
                    curr_square = (i//3, j//3, num)
                    
                    if curr_row in row or curr_col in col or curr_square in square:
                        return False
                    row.add(curr_row)
                    col.add(curr_col)
                    square.add(curr_square)
            return True
    
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.