Skip to content

[parkhojeong] WEEK 09 Solutions - #2832

Merged
parkhojeong merged 2 commits into
DaleStudy:mainfrom
parkhojeong:week9
Aug 22, 2026
Merged

[parkhojeong] WEEK 09 Solutions#2832
parkhojeong merged 2 commits into
DaleStudy:mainfrom
parkhojeong:week9

Conversation

@parkhojeong

@parkhojeong parkhojeong commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

๋‹ต์•ˆ ์ œ์ถœ ๋ฌธ์ œ

์ž‘์„ฑ์ž ์ฒดํฌ ๋ฆฌ์ŠคํŠธ

  • Projects์˜ ์˜ค๋ฅธ์ชฝ ๋ฒ„ํŠผ(โ–ผ)์„ ๋ˆŒ๋Ÿฌ ํ™•์žฅํ•œ ๋’ค, Week๋ฅผ ํ˜„์žฌ ์ฃผ์ฐจ๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
  • ๋ฌธ์ œ๋ฅผ ๋ชจ๋‘ ํ‘ธ์‹œ๋ฉด ํ”„๋กœ์ ํŠธ์—์„œ Status๋ฅผ In Review๋กœ ์„ค์ •ํ•ด์ฃผ์„ธ์š”.
  • ์ฝ”๋“œ ๊ฒ€ํ† ์ž 1๋ถ„ ์ด์ƒ์œผ๋กœ๋ถ€ํ„ฐ ์Šน์ธ์„ ๋ฐ›์œผ์…จ๋‹ค๋ฉด PR์„ ๋ณ‘ํ•ฉํ•ด์ฃผ์„ธ์š”.

๊ฒ€ํ† ์ž ์ฒดํฌ ๋ฆฌ์ŠคํŠธ

Important

๋ณธ์ธ ๋‹ต์•ˆ ์ œ์ถœ ๋ฟ๋งŒ ์•„๋‹ˆ๋ผ ๋‹ค๋ฅธ ๋ถ„ PR ํ•˜๋‚˜ ์ด์ƒ์„ ๋ฐ˜๋“œ์‹œ ๊ฒ€ํ† ๋ฅผ ํ•ด์ฃผ์…”์•ผ ํ•ฉ๋‹ˆ๋‹ค!

  • ๋ฐ”๋กœ ์ด์ „์— ์˜ฌ๋ผ์˜จ PR์— ๋ณธ์ธ์„ ์ฝ”๋“œ ๋ฆฌ๋ทฐ์–ด๋กœ ์ถ”๊ฐ€ํ•ด์ฃผ์„ธ์š”.
  • ๋ณธ์ธ์ด ๊ฒ€ํ† ํ•ด์•ผํ•˜๋Š” PR์˜ ๋‹ต์•ˆ ์ฝ”๋“œ์— ํ”ผ๋“œ๋ฐฑ์„ ์ฃผ์„ธ์š”.
  • ํ† ์š”์ผ ์ „๊นŒ์ง€ PR์„ ๋ณ‘ํ•ฉํ•  ์ˆ˜ ์žˆ๋„๋ก ์Šน์ธํ•ด์ฃผ์„ธ์š”.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿท๏ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํŒจํ„ด ๋ถ„์„

linked-list-cycle/parkhojeong.py
# Definition for singly-linked list.
# class ListNode:
#     def __init__(self, x):
#         self.val = x
#         self.next = None

class Solution:
    def hasCycle(self, head: Optional[ListNode]) -> bool:
        visited = set()
        cur = head

        while cur:
            if cur in visited:
                return True

            visited.add(cur)
            cur = cur.next

        return False
  • ํŒจํ„ด: Hash Map / Hash Set, Two Pointers
  • ์„ค๋ช…: head ํฌ์ธํ„ฐ๋ฅผ ์ˆœํšŒํ•˜๋ฉฐ ๋ฐฉ๋ฌธ ์—ฌ๋ถ€๋ฅผ ํ•ด์‹œ ์…‹์œผ๋กœ ์ถ”์ ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์‚ฌ์ดํด ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•ฉ๋‹ˆ๋‹ค. ํ•œ ๋ฒˆ ๋ฐฉ๋ฌธ๋œ ๋…ธ๋“œ๋ฅผ ์žฌ๋ฐฉ๋ฌธํ•˜๋ฉด ์‚ฌ์ดํด์ด ์กด์žฌํ•จ์„ ๋ฐ˜ํ™˜ํ•ฉ๋‹ˆ๋‹ค.

๐Ÿ“Š ์‹œ๊ฐ„/๊ณต๊ฐ„ ๋ณต์žก๋„ ๋ถ„์„

๋ณต์žก๋„
Time O(n)
Space O(n)

ํ”ผ๋“œ๋ฐฑ: ๊ฐ ๋…ธ๋“œ๋ฅผ ๋ฐฉ๋ฌธ ์—ฌ๋ถ€๋ฅผ ์ €์žฅํ•˜๋Š” ์ง‘ํ•ฉ์„ ์‚ฌ์šฉํ•ด ์ˆœํ™˜ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•ฉ๋‹ˆ๋‹ค. ์ตœ์•…์˜ ๊ฒฝ์šฐ ๋ชจ๋“  ๋…ธ๋“œ๋ฅผ ๊ฒ€์‚ฌํ•˜๋ฏ€๋กœ ์‹œ๊ฐ„ ๋ณต์žก๋„๋Š” ์„ ํ˜•์ด๊ณ , ์ถ”๊ฐ€ ์ €์žฅ ๊ณต๊ฐ„์€ ๋ฐฉ๋ฌธ ๋…ธ๋“œ ์ˆ˜์— ๋น„๋ก€ํ•ฉ๋‹ˆ๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ํ˜„์žฌ ๊ตฌํ˜„์ด ์ ์ ˆํ•ด ๋ณด์ž…๋‹ˆ๋‹ค.

๐Ÿ’ก ํ’€์ด์— ์‹œ๊ฐ„/๊ณต๊ฐ„ ๋ณต์žก๋„๋ฅผ ์ฃผ์„์œผ๋กœ ๋‚จ๊ฒจ๋ณด์„ธ์š”!

@dalestudy

dalestudy Bot commented Aug 22, 2026

Copy link
Copy Markdown
Contributor

๐Ÿ“Š parkhojeong ๋‹˜์˜ ํ•™์Šต ํ˜„ํ™ฉ

์ด๋ฒˆ ์ฃผ ์ œ์ถœ ๋ฌธ์ œ

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
linked-list-cycle Easy โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜
pacific-atlantic-water-flow Medium โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜

๋ˆ„์  ํ•™์Šต ์š”์•ฝ

  • ํ’€์ดํ•œ ๋ฌธ์ œ: 39 / 75๊ฐœ
  • ์ด๋ฒˆ ์ฃผ ์œ ํ˜• ์ผ์น˜์œจ: 0% (2๋ฌธ์ œ ์ค‘ 0๋ฌธ์ œ ์ผ์น˜)

๋ฌธ์ œ ํ’€์ด ํ˜„ํ™ฉ

์นดํ…Œ๊ณ ๋ฆฌ ์ง„ํ–‰๋„ ์™„๋ฃŒ
Array โ– โ– โ– โ– โ– โ– โ–ก 8 / 10 (Medium 5, Easy 3)
String โ– โ– โ– โ– โ– โ– โ–ก 8 / 10 (Medium 5, Easy 3)
Matrix โ– โ– โ– โ– โ– โ–กโ–ก 3 / 4 (Medium 3)
Dynamic Programming โ– โ– โ– โ– โ– โ–กโ–ก 8 / 11 (Easy 1, Medium 7)
Binary โ– โ– โ– โ–กโ–กโ–กโ–ก 2 / 5 (Easy 2)
Graph โ– โ– โ– โ–กโ–กโ–กโ–ก 3 / 8 (Medium 3)
Linked List โ– โ– โ–กโ–กโ–กโ–กโ–ก 2 / 6 (Easy 2)
Heap โ– โ– โ–กโ–กโ–กโ–กโ–ก 1 / 3 (Medium 1)
Tree โ– โ– โ–กโ–กโ–กโ–กโ–ก 4 / 14 (Medium 3, Easy 1)
Interval โ–กโ–กโ–กโ–กโ–กโ–กโ–ก 0 / 5 โ† ์•„์ง ์‹œ์ž‘ ์•ˆ ํ•จ

๐Ÿค– ์ด ๋Œ“๊ธ€์€ GitHub App์„ ํ†ตํ•ด ์ž๋™์œผ๋กœ ์ž‘์„ฑ๋˜์—ˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 879 108 987 $0.000087

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๐Ÿท๏ธ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ํŒจํ„ด ๋ถ„์„

pacific-atlantic-water-flow/parkhojeong.py
class Solution:
    def pacificAtlantic(self, heights: List[List[int]]) -> List[List[int]]:
        pacific_set = set()
        atlantic_set = set()

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

        DIR = [(-1, 0), (1, 0), (0, -1), (0, 1)]

        def dfs(start: tuple[int], row: int, col: int, prev_water: int, prev: set[int]):
            if (row, col) in prev:
                return

            prev.add((row, col))

            if prev_water < heights[row][col]:
                return

            if row == 0 or col == 0:
                pacific_set.add(start)

            if row == m - 1 or col == n - 1:
                atlantic_set.add(start)

            for dr, dc in DIR:
                next_r, next_c = row + dr, col + dc
                if 0 <= next_r < m and 0 <= next_c < n and heights[row][col] >= heights[next_r][next_c]:
                    dfs(start, next_r, next_c, heights[row][col], prev)


        for row in range(m):
            for col in range(n):
                prev = set()
                dfs((row, col), row, col, 10000000, prev)

        res = []
        for row in range(m):
            for col in range(n):
                if (row, col) in pacific_set and (row, col) in atlantic_set:
                    res.append((row, col))

        return res
  • ํŒจํ„ด: Depth-First Search, Backtracking, Dynamic Programming
  • ์„ค๋ช…: ์ฝ”๋“œ๋Š” ๊ฐ ์…€์—์„œ DFS๋ฅผ ํ†ตํ•ด ์ธ์ ‘ํ•œ ์…€๋กœ ์ด๋™ํ•˜๋ฉฐ ๋†’์ด ์กฐ๊ฑด์„ ๋งŒ์กฑํ•˜๋Š” ๊ฒฝ๋กœ๋ฅผ ํƒ์ƒ‰ํ•ฉ๋‹ˆ๋‹ค. ์—ฌ๋Ÿฌ ์‹œ์ž‘์ ์—์„œ ๋ฐฑํŠธ๋ž˜ํ‚น ํ˜•ํƒœ๋กœ ํƒ์ƒ‰ํ•˜๊ณ , ๋‘ ๋ฐฉํ–ฅ ๋ฐ”๋‹ค์— ๋„๋‹ฌํ•˜๋Š”์ง€ ์ถ”์ ํ•˜๋Š” ๋ฐฉ์‹์ด ํฌํ•จ๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋‹ค๋งŒ ๋ช…์‹œ์  DP ์ตœ์ ํ™” ์—†์ด DFS ๊ธฐ๋ฐ˜ ํƒ์ƒ‰๊ณผ ๋ฐฑํŠธ๋ž˜ํ‚น์ด ์ฃผ๋ฅผ ์ด๋ฃน๋‹ˆ๋‹ค.

๐Ÿ“Š ์‹œ๊ฐ„/๊ณต๊ฐ„ ๋ณต์žก๋„ ๋ถ„์„

๋ณต์žก๋„
Time O(mn(m+n))
Space O(m*n)

ํ”ผ๋“œ๋ฐฑ: ๊ฐ ์…€์— ๋Œ€ํ•ด DFS๋ฅผ ์ˆ˜ํ–‰ํ•˜๊ณ , ์žฌ๋ฐฉ๋ฌธ์„ ๋ง‰๊ธฐ ์œ„ํ•ด ๊ฐ ํƒ์ƒ‰๋งˆ๋‹ค ๋ฐฉ๋ฌธ ์ง‘ํ•ฉ์„ ์‚ฌ์šฉํ•œ๋‹ค. ์ด๋กœ ์ธํ•ด ์ค‘๋ณต ํƒ์ƒ‰์ด ๋งŽ์•„ ๋น„ํšจ์œจ์ ์ผ ์ˆ˜ ์žˆ๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ๊ณ ๋ คํ•ด๋ณผ ๋งŒํ•œ ๋Œ€์•ˆ: ์–‘๋ฐฉํ–ฅ BFS๋ฅผ ๊ฐ๊ฐ์˜ ๋ฐ”๋‹ค์—์„œ ์‹œ์ž‘ํ•ด ๋„๋‹ฌ ๊ฐ€๋Šฅํ•œ ์…€์„ ๊ตฌํ•˜๊ณ  ๊ต์ง‘ํ•ฉ์„ ์ฐพ๋Š” ๋ฐฉ์‹์œผ๋กœ ์‹œ๊ฐ„ ๋ณต์žก๋„๋ฅผ O(m*n)์œผ๋กœ ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

๐Ÿ’ก ํ’€์ด์— ์‹œ๊ฐ„/๊ณต๊ฐ„ ๋ณต์žก๋„๋ฅผ ์ฃผ์„์œผ๋กœ ๋‚จ๊ฒจ๋ณด์„ธ์š”!

@ICE0208 ICE0208 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

9์ฃผ์ฐจ ๋ฌธ์ œ ํ’€์ด๋„ ์ˆ˜๊ณ  ๋งŽ์œผ์…จ์Šต๋‹ˆ๋‹ค! ๐Ÿ‘

@ICE0208 ICE0208 Aug 22, 2026

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

visited ๋ฅผ ์‚ฌ์šฉํ•ด์„œ ์ด์ „์— ๋ฐฉ๋ฌธํ•œ ๋…ธ๋“œ์ธ์ง€ ํŒ๋‹จํ•˜๋Š” ๋กœ์ง์ด ์ง๊ด€์ ์ด๋ผ ์ดํ•ดํ•˜๊ธฐ ์‰ฝ๋„ค์š”!
ํ”Œ๋กœ์ด๋“œ ์ˆœํ™˜ ์ฐพ๊ธฐ ์•Œ๊ณ ๋ฆฌ์ฆ˜ ์„ ์ด์šฉํ•ด์„œ ๊ณต๊ฐ„ ๋ณต์žก๋„๋ฅผ ์ค„์ผ ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๊ทธ๋ ‡๊ฒŒ๋„ ํ•œ ๋ฒˆ ํ’€์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

์ €๋„ ์ฒ˜์Œ์—๋Š” ๊ฐ ์ขŒํ‘œ์—์„œ DFS๋ฅผ ์‹œ์ž‘ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ’€์—ˆ๋Š”๋ฐ, ์ƒ๊ฐํ•ด์•ผ ํ•  ์กฐ๊ฑด์ด ๋งŽ์•„ ์กฐ๊ธˆ ๋ณต์žกํ•ด์ง€๋”๋ผ๊ณ ์š”!
๋ฐ˜๋Œ€๋กœ ๊ฐ ๋ฐ”๋‹ค์˜ ๊ฒฝ๊ณ„์—์„œ ์‹œ์ž‘ํ•ด์„œ ๋„๋‹ฌ ๊ฐ€๋Šฅํ•œ ์ขŒํ‘œ๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ํ’€์–ด๋ณด๋‹ˆ ์กฐ๊ธˆ ๋” ๊ฐ„๋‹จํ•˜๊ฒŒ ๊ตฌํ˜„ํ•  ์ˆ˜ ์žˆ์—ˆ์Šต๋‹ˆ๋‹ค. ์ฐธ๊ณ ์šฉ์œผ๋กœ ์ฝ”๋ฉ˜ํŠธ ๋‚จ๊ฒจ๋†“์Šต๋‹ˆ๋‹ค :)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

๋ฐ˜๋Œ€๋กœ ์‹œ์ž‘ํ•˜๋Š” ๊ฒƒ๋„ ๊ดœ์ฐฎ๊ฒ ๋„ค์š”. ์•Œ๋ ค์ฃผ์‹  ๋ฐฉ์‹์œผ๋กœ๋„ ํ’€์–ด๋ณด๊ฒ ์Šต๋‹ˆ๋‹ค. ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค!

@parkhojeong
parkhojeong merged commit 369e5ca into DaleStudy:main Aug 22, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

2 participants