From a8cf9a48071e47501ff77b87eee4c7f61daa2a37 Mon Sep 17 00:00:00 2001 From: ImAlpha Date: Tue, 22 Aug 2023 23:30:34 -0700 Subject: [PATCH] updated to matrix method to check validity --- .../Arrays_and_Hashing/36_Valid_Sudoku.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/NeetCodeRoadmap/Arrays_and_Hashing/36_Valid_Sudoku.py b/NeetCodeRoadmap/Arrays_and_Hashing/36_Valid_Sudoku.py index 3251743..c41ed10 100644 --- a/NeetCodeRoadmap/Arrays_and_Hashing/36_Valid_Sudoku.py +++ b/NeetCodeRoadmap/Arrays_and_Hashing/36_Valid_Sudoku.py @@ -3,10 +3,14 @@ def isValidSudoku(board): :type board: List[List[str]] :rtype: bool """ - x = [] - y = [] - for x in board: - + temp = [] + for x in range(len(board)): + for y in range(len(board[x])): + if y not in temp: + temp.append(board[x]) + else: + return False + print(isValidSudoku([["5","3",".",".","7",".",".",".","."] ,["6",".",".","1","9","5",".",".","."]