Update diagonal_traversal.py to adhere ruff suggestions

This commit is contained in:
Anubhav Joshi 2024-10-05 19:12:43 +05:30 committed by GitHub
parent ba3cf0aa00
commit 204c38836b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,14 +45,14 @@ def find_diagonal_order(mat: list[list[int]]) -> list[int]:
else: # move up diagonally
row -= 1
col += 1
else: # moving down
if row == m - 1: # hit the bottom boundary
col += 1
elif col == 0: # hit the left boundary
row += 1
else: # move down diagonally
row += 1
col -= 1
elif row == m - 1: # hit the bottom boundary
col += 1
elif col == 0: # hit the left boundary
row += 1
elif col > 0 and row < m - 1: # move down diagonally
row += 1
col -= 1
return result