68ms solution with python


  • 0
    Y
    class Solution(object):
        def isValidSudoku(self, board):
            """
            :type board: List[List[str]]
            :rtype: bool
            """
            a = []
            for rowi,row in enumerate(board):
                for colj,value in enumerate(row):
                    if value != '.':
                        if (rowi,value) in a or (colj+9, value) in a or (rowi/3*3+colj/3+18,value) in a: return False
                        a += [(rowi,value),(colj+9, value),(rowi/3*3+colj/3+18, value)]
            return True

  • 0
    C
    This post is deleted!

  • 0
    W
    This post is deleted!

Log in to reply
 

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