mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-10-05 21:29:29 +00:00
Update diagonal_traversal.py to adhere ruff suggestions
This commit is contained in:
parent
ba3cf0aa00
commit
204c38836b
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user