mirror of
https://github.com/TheAlgorithms/Python.git
synced 2024-10-05 21:29:29 +00:00
Compare commits
2 Commits
ba3cf0aa00
...
621a09f074
Author | SHA1 | Date | |
---|---|---|---|
|
621a09f074 | ||
|
204c38836b |
|
@ -45,14 +45,13 @@ 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