## PYTHON CODE FOR THIS PROBLEM def is_valid_sudoku(board): # Initialize dictionaries to keep track of seen numbers rows = {i: set() for i in range(9)} # HashMap for rows columns = {j: set() for j in range(9)} # HashMap for columns boxes = {k: set() for k in range(9)} # HashMap for boxes # Checking rows for i in range(9): for j in range(9): num = board[i][j] if num != '.': if num in rows[i]: return False rows[i].add(num) # Checking columns for j in range(9): for i in range(9): num = board[i][j] if num != '.': if num in columns[j]: return False columns[j].add(num) # Checking boxes for i in range(9): for j in range(9): num = board[i][j] if num != '.': box_index = 3 * (i // 3) + (j // 3) if num in boxes[box_index]: return False boxes[box_index].add(num) return True
def isValidSudoku(self, board: List[List[str]]) -> bool: for i in range(len(board)): row_check=[] col_check=[] for j in range(len(board)): if board[i][j]!=".": if board[i][j] in row_check: return False row_check.append(board[i][j]) if board[j][i]!=".": if board[j][i] in col_check: return False col_check.append(board[j][i]) start_row=start=0 row_end=col_end=3 for i in range(3): for _ in range(3): temp=[] for j in range(start_row,row_end): for k in range(start,col_end): if board[j][k]!=".": if board[j][k] in temp: return False temp.append(board[j][k]) start+=3 col_end+=3 start_row+=3 row_end+=3 start=0 col_end=3 return True Bro ee code ki leetcode lo O(1) time complexity ani istundi , is it true?
Neetcode is nothing but some set of problems from leet code..oka athanu neetcode aney platform create cheysi andhulo only important codes from leetcode pick chesi thanu neetcode lo manaku provide chestunnadu..
@@bharathh_chandraa ante i mean concept explain cheyochu kada ani telugu lo kuda antha effective gha evar explain cheyatle so mik kuda subscriber count perugutadhi kada
anna miru different approaches vadthunnaru and vatiki code kuda chupinchi oka 1 min explanation isthe chala bavuntadhi and useful untdhi anna.
Awesome explaination Anna ❤ !
Ilane anni different patterns questions meda videos cheyandi anna chala useful iythadi !!
Sure sidharth. Already 7 most asked questions meedha already videos release chesa, take a look!
@@bharathh_chandraa Yeah anna playlist ni follow avthunna !!
Very good content brother. Keep it up. Good content on sudoko lectures.
## PYTHON CODE FOR THIS PROBLEM
def is_valid_sudoku(board):
# Initialize dictionaries to keep track of seen numbers
rows = {i: set() for i in range(9)} # HashMap for rows
columns = {j: set() for j in range(9)} # HashMap for columns
boxes = {k: set() for k in range(9)} # HashMap for boxes
# Checking rows
for i in range(9):
for j in range(9):
num = board[i][j]
if num != '.':
if num in rows[i]:
return False
rows[i].add(num)
# Checking columns
for j in range(9):
for i in range(9):
num = board[i][j]
if num != '.':
if num in columns[j]:
return False
columns[j].add(num)
# Checking boxes
for i in range(9):
for j in range(9):
num = board[i][j]
if num != '.':
box_index = 3 * (i // 3) + (j // 3)
if num in boxes[box_index]:
return False
boxes[box_index].add(num)
return True
8/150✅️
Clear cut explanation Anna. If you need any blog web site, I will help you, thanks ( free cost ) for providing great content.
anna super, do more videos .
Hi Bharath, when explaining 3rd HashTable middle 3x3 values store in key 4 it will not store key5.
Yes, you are right! Thanks for pointing out
No need to create blog bro.. just push to your github repo.
If this is the brute force approach what is the optimal approach ?
Bro videos oka order lo chwy bro like coding problems neetcode 150 lo order untay kadha ala cheystey chala help avutundhi
Neetcode 150 order lone vastunnay Siva videos. Neetcode 1-8/ 150 playlist lo aready unnay. 9/150 repu release avtundi
@@bharathh_chandraa k bro thank you 😊
Anna,if possible try to come up with two problems a day. Crazy ardham avthundhi asalu ❤
Chedham Saketh. Quality and Quantity rendu baagundaalani try chestunna
Bro try to cover 2 problems per day pls
nee cf handle share chey bro
Hi bro emi language use chesthunav
def isValidSudoku(self, board: List[List[str]]) -> bool:
for i in range(len(board)):
row_check=[]
col_check=[]
for j in range(len(board)):
if board[i][j]!=".":
if board[i][j] in row_check:
return False
row_check.append(board[i][j])
if board[j][i]!=".":
if board[j][i] in col_check:
return False
col_check.append(board[j][i])
start_row=start=0
row_end=col_end=3
for i in range(3):
for _ in range(3):
temp=[]
for j in range(start_row,row_end):
for k in range(start,col_end):
if board[j][k]!=".":
if board[j][k] in temp:
return False
temp.append(board[j][k])
start+=3
col_end+=3
start_row+=3
row_end+=3
start=0
col_end=3
return True
Bro ee code ki leetcode lo O(1) time complexity ani istundi , is it true?
Neet code ante enti anna yt channel aa
Neetcode is nothing but some set of problems from leet code..oka athanu neetcode aney platform create cheysi andhulo only important codes from leetcode pick chesi thanu neetcode lo manaku provide chestunnadu..
@@SivaTechVerse thank u for replying
hello anna miru dsa topics explain cheyochu kada oka seies laaga please
Problems solve cheyadaaniki kaavalsina topics annitini cover chestu videos chestune unna. Seperate playlist lo pettadaaniki try chestha vaatini
@@bharathh_chandraa ante i mean concept explain cheyochu kada ani telugu lo kuda antha effective gha evar explain cheyatle so mik kuda subscriber count perugutadhi kada