Skip to content

[sangbeenmoon] WEEK 05 Solutions - #2776

Merged
sangbeenmoon merged 1 commit into
DaleStudy:mainfrom
sangbeenmoon:main
Jul 26, 2026
Merged

[sangbeenmoon] WEEK 05 Solutions#2776
sangbeenmoon merged 1 commit into
DaleStudy:mainfrom
sangbeenmoon:main

Conversation

@sangbeenmoon

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jul 25, 2026

Copy link
Copy Markdown
Contributor

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

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
group-anagrams Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
implement-trie-prefix-tree Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
word-break Medium โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜

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

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

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

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

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

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 1,626 137 1,763 $0.000136
2 1,583 146 1,729 $0.000138
ํ•ฉ๊ณ„ 3,209 283 3,492 $0.000274

Comment thread group-anagrams/sangbeenmoon.py Outdated
Comment on lines +45 to +51
if sorted_target in d:
group = d[sorted_target]
group.append(target)
d[sorted_target] = group.copy()
else:
group = [target]
d[sorted_target] = group.copy()

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.

        if sorted_target in d:
            d[sorted_target].append(target)
        else:
            d[sorted_target] = [target]

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.

์ด๋ ‡๊ฒŒ ํ•˜์‹œ๋Š”๊ฒŒ ํ›จ์”ฌ ๋‚˜์„๊ฑฐ์—์š”, ์ง€๊ธˆ ์ฝ”๋“œ์—์„œ copy๋Š” ์˜๋ฏธ๋ฅผ ๋ชจ๋ฅด๊ฒ ์–ด์š”

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.

๋„ค ๊น”๋”ํ•˜๋„ค์š” ใ…Žใ…Ž ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

Comment thread group-anagrams/sangbeenmoon.py Outdated
for candidate in d.values():
answer.append(candidate)

return answer

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.

list(d.values())

์ด๋ ‡๊ฒŒ ๋ฆฌ์ŠคํŠธ๋กœ ํ˜•๋ณ€ํ™˜ ํ•˜์‹œ๋ฉด answer ์—†์ด ๋ฐ”๋กœ ๊ฐ€๋Šฅํ•˜์„ธ์š”

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 left a comment

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.

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค.

class TrieNode:

def __init__(self):
self.d = {}

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.

d๊ฐ€ ๋ฌด์Šจ ์•ฝ์–ด์ผ๊นŒ์š”?

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.

dictionary ์˜ ์•ฝ์–ด๋กœ ์‚ฌ์šฉํ–ˆ๋Š”๋ฐ์š”, ์ข€ ๋” ๊ฐ€๋…์„ฑ ์žˆ๊ฒŒ ๋„ค์ด๋ฐ ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!

Comment thread word-break/sangbeenmoon.py Outdated
class Solution:
def wordBreak(self, s: str, wordDict: List[str]) -> bool:

d = {}

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.

์˜๋ฏธ์— ๋งž๋Š” ๋„ค์ด๋ฐ์„ ํ•ด์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.

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.

๋„ค ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!

Comment thread group-anagrams/sangbeenmoon.py Outdated
Comment on lines +48 to +51
d[sorted_target] = group.copy()
else:
group = [target]
d[sorted_target] = group.copy()

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.

copy ์“ฐ์‹  ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

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.

๋ถˆํ•„์š”ํ•œ ๋ถ€๋ถ„์ด๋ผ ์ œ๊ฑฐํ–ˆ์Šต๋‹ˆ๋‹ค!

Comment on lines +20 to +29
node.insert(word[1:])

def search(self, word):
if word == "":
return self.is_end

target = word[0]

if target in self.d:
return self.d[target].search(word[1:])

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.

[1:]์ด O(n)์ด๋ผ ํ˜„์žฌ insert, search์—์„œ ํƒ์ƒ‰ ์„ฑ๋Šฅ์ด ์ข‹์ง€ ์•Š์€ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค. [1:]์„ ์‚ฌ์šฉํ•˜์ง€ ์•Š๊ณ  ๊ตฌํ˜„ํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.

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.

๋„ค index ๋ฅผ ๋„˜๊ธฐ๋„๋ก ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค.

Comment on lines +45 to +57
class Trie:

def __init__(self):
self.root = TrieNode()

def insert(self, word: str) -> None:
self.root.insert(word)

def search(self, word: str) -> bool:
return self.root.search(word)

def startsWith(self, prefix: str) -> bool:
return self.root.startsWith(prefix)

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.

Trie์—๋Š” ๊ตฌํ˜„์ด ์—†๊ณ  TrieNode์— ๋ชจ๋“  ๊ตฌํ˜„์„ ํ•˜์‹  ์ด์œ ๊ฐ€ ์žˆ์„๊นŒ์š”?

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.

root ์ฒ˜๋ฆฌ๊ฐ€ ๊น”๋”ํ• ๊นŒ ์‹ถ์–ด์„œ TrieNode ์— ๊ตฌํ˜„ํ–ˆ๋˜ ๊ฒƒ์ธ๋ฐ์š”, Trie ์— ์ง์ ‘ ๊ตฌํ˜„ํ•˜๋Š” ๊ฒƒ๋„ ๋ฐฉ๋ฒ•์ด์—ˆ๋„ค์š” ใ…Žใ…Ž ์ˆ˜์ •ํ–ˆ์Šต๋‹ˆ๋‹ค!

@parkhojeong parkhojeong left a comment

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.

์ด๋ฒˆ ์ฃผ์ฐจ ํ’€์ด์™€ ๊ด€๊ณ„ ์—†๋Š” ์ปค๋ฐ‹ ๋กœ๊ทธ๋Š” ์ •๋ฆฌ ๋ถ€ํƒ๋“œ๋ฆฌ๊ณ  ๋ฆฌ๋ทฐ ์ปค๋ฉ˜ํŠธ๋„ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

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.

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

  • ํŒจํ„ด: Hash Map / Hash Set, Sorting
  • ์„ค๋ช…: ์ฒซ ๋ฒˆ์งธ ํ’€์ด์—์„œ ๊ฐ ๋ฌธ์ž์—ด์„ ์ •๋ ฌํ•œ ๊ฒฐ๊ณผ๋ฅผ ํ‚ค๋กœ ์‚ผ์•„ ๊ทธ๋ฃนํ™”ํ•˜๋ ค๊ณ  ํ•˜๋ฉฐ, ๋‘ ๋ฒˆ์งธ ํ’€์ด๋„ ์ •๋ ฌ๋œ ๋ฌธ์ž์—ด์„ ํ‚ค๋กœ ์‚ฌ์ „์‹ ๋งคํ•‘ํ•˜์—ฌ ๊ฐ™์€ ์•„๋‚˜๊ทธ๋žจ ๋ฌถ์Œ์„ ๊ตฌ์„ฑํ•ฉ๋‹ˆ๋‹ค. ํšจ์œจ์ ์ธ ๊ทธ๋ฃนํ™”๋ฅผ ์œ„ํ•ด ํ•ด์‹œ ๋งต์„ ์‚ฌ์šฉํ•ฉ๋‹ˆ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ๋‘ ๊ฐ€์ง€ ๊ตฌํ˜„ ๋ชจ๋‘ ์„œ๋กœ ๋‹ค๋ฅธ ์‹œ๊ฐ„ ๋ณต์žก๋„๋กœ ๊ทธ๋ฃน์„ ์ฐพ์ง€๋งŒ ๋‘ ๋ฒˆ์งธ ๊ตฌํ˜„์ด ์ผ๋ฐ˜์ ์œผ๋กœ ๋” ๊ฐ„๋‹จํ•˜๊ณ  ํšจ์œจ์ ์ด๋‹ค.

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

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

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.

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

  • ํŒจํ„ด: Trie, Depth-First Search, Hash Map / Hash Set
  • ์„ค๋ช…: ํŠธ๋ผ์ด ๊ตฌ์กฐ๋ฅผ ์ด์šฉํ•œ ๋ฌธ์ž์—ด ๊ตฌ์„ฑ ์š”์†Œ ํƒ์ƒ‰์œผ๋กœ ๊ฐ ๋…ธ๋“œ์˜ ์ž์‹ ๋ฐ ๋ ์—ฌ๋ถ€๋ฅผ ์žฌ๊ท€์ ์œผ๋กœ ๊ด€๋ฆฌํ•ฉ๋‹ˆ๋‹ค. ์‚ฝ์ž…/๊ฒ€์ƒ‰/์ ‘๋‘์–ด ํƒ์ƒ‰์€ ๊นŠ์ด ์šฐ์„  ๋ฐฉ์‹์œผ๋กœ ํŠธ๋ฆฌ๋ฅผ ๋”ฐ๋ผ ๋‚ด๋ ค๊ฐ€๋ฉฐ ๊ตฌํ˜„๋ฉ๋‹ˆ๋‹ค.

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

๋ณต์žก๋„
Time O(L)
Space O(์•ŒํŒŒ๋ฒณ ์ˆ˜ * ๋…ธ๋“œ ์ˆ˜)

ํ”ผ๋“œ๋ฐฑ: ํŠธ๋ผ์ด ๊ตฌ์กฐ๋ฅผ ์žฌ๊ท€๋กœ ๊ตฌํ˜„ํ–ˆ์œผ๋ฉฐ ๊ฐ ํ˜ธ์ถœ์ด ๋‚จ์€ ๋ฌธ์ž์—ด ๊ธธ์ด์— ๋น„๋ก€ํ•œ๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ๋ฉ”๋ชจ๋ฆฌ ์ ˆ์•ฝ์„ ์œ„ํ•ด ํด๋ž˜์Šค ๋ฉค๋ฒ„ ๋ณ€์ˆ˜๋ฅผ ์ธ์Šคํ„ด์Šค๋ณ„๋กœ ๊ด€๋ฆฌํ•˜๊ณ  ์ตœ์ ํ™”ํ•  ์ˆ˜ ์žˆ๋‹ค.

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

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.

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

  • ํŒจํ„ด: Dynamic Programming, Hash Map / Hash Set
  • ์„ค๋ช…: ๋ถ€๋ถ„ ๋ฌธ์ž์—ด๋กœ ๊ฐ€๋Šฅํ•œ ๋‹จ์–ด๋ฅผ ํ™•์ธํ•˜๋ฉฐ DP + ์žฌ๊ท€ ํƒ์ƒ‰์œผ๋กœ ๋ถ€๋ถ„ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋ ค๋Š” ๊ตฌ์กฐ์™€, ๋‹จ์–ด ์ง‘ํ•ฉ์„ ํ•ด์‹œ ๋งต์œผ๋กœ ๋น ๋ฅด๊ฒŒ ์กฐํšŒํ•˜๋Š” ํŒจํ„ด์ด ํ•ต์‹ฌ์ž…๋‹ˆ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ์ฃผ์„์˜ ์‹คํŒจํ•œ ํ’€์ด๋ฅผ ์ œ๊ฑฐํ•˜๊ณ  ์‹ค์ œ DP ํ’€์ด๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ๋‹ค. ํ˜„์žฌ ๊ตฌํ˜„์€ ์žฌ๊ท€๋ฅผ ์‚ฌ์šฉํ•œ ํƒ์ƒ‰์œผ๋กœ ๊ฐ€๋…์„ฑ์€ ์ข‹์œผ๋‚˜ ์ตœ์•…์˜ ๊ฒฝ์šฐ ์‹œ๊ฐ„๋ณต์žก๋„์— ์ฃผ์˜๊ฐ€ ํ•„์š”ํ•˜๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ์ถ”๊ฐ€์ ์ธ ๋ฉ”๋ชจ์ด์ œ์ด์…˜(dp ๋ฐฐ์—ด)๊ณผ ๋ฐฉ๋ฌธ ์ฒดํฌ๋ฅผ ๋” ๋ช…ํ™•ํžˆ ํ•˜์—ฌ ๋ถˆํ•„์š”ํ•œ ์žฌํƒ์ƒ‰์„ ์ค„์ด๋„๋ก ๊ฐœ์„ ํ•ด๋ณด์ž.

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

@sangbeenmoon
sangbeenmoon requested a review from parkhojeong July 26, 2026 07:28
@sangbeenmoon
sangbeenmoon merged commit 002608e into DaleStudy:main Jul 26, 2026
1 check 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.

3 participants