Skip to content

Commit ee79d4e

Browse files
authored
Update minimum-number-of-visited-cells-in-a-grid.py
1 parent fd0a678 commit ee79d4e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

Python/minimum-number-of-visited-cells-in-a-grid.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,13 @@ def minimumVisitedCells(self, grid):
5454
while uf1[i].right_set(j) <= min(j+grid[i][j], n-1):
5555
k = uf1[i].right_set(j)
5656
new_q.append((i, k))
57-
uf1[i].union_set(k, k+1)
5857
uf2[k].union_set(i, i+1)
58+
uf1[i].union_set(k, k+1)
5959
while uf2[j].right_set(i) <= min(i+grid[i][j], m-1):
6060
k = uf2[j].right_set(i)
6161
new_q.append((k, j))
62-
uf2[j].union_set(k, k+1)
6362
uf1[k].union_set(j, j+1)
63+
uf2[j].union_set(k, k+1)
6464
q = new_q
6565
d += 1
6666
return -1

0 commit comments

Comments
 (0)