Skip to content

Commit 374ca27

Browse files
authored
Update Pacific Atlantic Water Flow - Leetcode 417.py
1 parent 442fe0b commit 374ca27

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

Pacific Atlantic Water Flow - Leetcode 417.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,25 +2,26 @@
22

33
class Solution:
44
def pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:
5-
# Note: If you watched the video for this, you would have seen slightly
6-
# different code that uses another set called "coords". You don't need this,
7-
# because we can just use the intersection of a_seen and p_seen instead!
8-
95
p_que = deque()
106
p_seen = set()
7+
118
a_que = deque()
129
a_seen = set()
10+
1311
m, n = len(heights), len(heights[0])
1412

1513
for j in range(n):
1614
p_que.append((0, j))
1715
p_seen.add((0, j))
16+
1817
for i in range(1, m):
1918
p_que.append((i, 0))
2019
p_seen.add((i, 0))
20+
2121
for i in range(m):
2222
a_que.append((i, n - 1))
2323
a_seen.add((i, n - 1))
24+
2425
for j in range(n - 1):
2526
a_que.append((m - 1, j))
2627
a_seen.add((m - 1, j))

0 commit comments

Comments
 (0)