Skip to content

[shinsj4653] Week 10 Solutions #1546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions course-schedule/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions invert-binary-tree/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions jump-game/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions linked-list-cycle/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions maximum-product-subarray/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions merge-k-sorted-lists/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions minimum-window-substring/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


71 changes: 71 additions & 0 deletions pacific-atlantic-water-flow/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


class Solution:
def pacificAtlantic(heights):
ret = []

dy = [-1, 0, 1, 0]
dx = [0, 1, 0, -1]

n, m = len(heights), len(heights[0])

def isPacific(y, x): # pacific 도달 가능한지
if y == 0 or (0 <= y < n and x == 0):
return True

else:
return False

def isAtlantic(y, x): # Atlantic 도달 가능한지
if y == n - 1 or (0 <= y < n and x == m - 1):
return True

else:
return False

def inRange(y, x):
if 0 <= y < n and 0 <= x < m:
return True
else:
return False

v = [[False for _ in range(m)] for _ in range(n)]

def dfs(y, x, heights, v):
if isPacific(y, x) and isAtlantic(y, x):
return True

v[y][x] = True

for i in range(4):
ny, nx = y + dy[i], x + dx[i]
if inRange(ny, nx) and not v[ny][nx] and \
heights[y][x] >= heights[ny][nx]:
if dfs(ny, nx, heights, v):
return True

v[y][x] = False
return False

for i in range(n):
for j in range(m):
if dfs(i, j, heights, v):
ret.append((i, j))

return ret

pacificAtlantic([[1,2,2,3,5],[3,2,3,4,4],[2,4,5,3,1],[6,7,1,4,5],[5,1,1,2,4]])

15 changes: 15 additions & 0 deletions search-in-rotated-sorted-array/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""


15 changes: 15 additions & 0 deletions sum-of-two-integers/shinsj4653.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"""
[문제풀이]
# Inputs

# Outputs

# Constraints

# Ideas

[회고]

"""