Skip to content

[dolphinflow86] WEEK 05 Solutions#2762

Open
dolphinflow86 wants to merge 3 commits into
DaleStudy:mainfrom
dolphinflow86:main
Open

[dolphinflow86] WEEK 05 Solutions#2762
dolphinflow86 wants to merge 3 commits into
DaleStudy:mainfrom
dolphinflow86:main

Conversation

@dolphinflow86

@dolphinflow86 dolphinflow86 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
best-time-to-buy-and-sell-stock Easy โœ… ์˜๋„ํ•œ ์œ ํ˜•
encode-and-decode-strings Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
group-anagrams Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•

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

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

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

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

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

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 325 53 378 $0.000037
2 669 84 753 $0.000067
3 1,093 118 1,211 $0.000102
ํ•ฉ๊ณ„ 2,087 255 2,342 $0.000206

@okyungjin

okyungjin commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@dolphinflow86 ์•ˆ๋…•ํ•˜์„ธ์š”~ ์ƒํƒœ In Review๋กœ ์„ค์ •๋˜์–ด ์žˆ๋Š”๋ฐ ์˜๋„ํ•˜์‹ ๊ฒŒ ๋งž๋Š”์ง€ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

@dolphinflow86

dolphinflow86 commented Jul 20, 2026

Copy link
Copy Markdown
Contributor Author

@dolphinflow86 ์•ˆ๋…•ํ•˜์„ธ์š”~ ์ƒํƒœ In Review๋กœ ์„ค์ •๋˜์–ด ์žˆ๋Š”๋ฐ ์˜๋„ํ•˜์‹ ๊ฒŒ ๋งž๋Š”์ง€ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค!

์•ˆ๋…•ํ•˜์„ธ์š”! In Review๋กœ ๋œ ๊ฒƒ์€ ์˜๋„๊ฐ€ ๋งž์Šต๋‹ˆ๋‹ค. ์˜ˆ์ „์— ์Šคํ„ฐ๋”” ๊ฐ€์ด๋“œ์ชฝ์—์„œ ๋ฏธ๋ฆฌ PR์„ ์˜ฌ๋ฆฌ๊ณ  ๋ฆฌ๋ทฐ๋ฅผ ๊ธธ๊ฒŒ ๋ฐ›์œผ๋ฉด์„œ ๊ฐ€๋Š”๊ฒŒ ์ข‹๋‹ค๊ณ  ํ•˜์‹ ๊ฑธ ๋ณธ์ ์ด ์žˆ์–ด์„œ์š”. In Review๋กœ ๋ฐ”๊พธ๋Š” ๊ฒƒ์€ ์ œ๊ฐ€ ์ž˜๋ชป ๋ดค์„์ˆ˜๋„ ์žˆ์Šต๋‹ˆ๋‹ค -> Solving์œผ๋กœ ๋ฐ”๊ฟ”๋†“์•˜์Šต๋‹ˆ๋‹ค~

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.

๊น”๋”ํ•˜๊ฒŒ ์ž˜ ํ•ด๊ฒฐํ•ด ์ฃผ์…จ๋„ค์š”!
best time to buy and sell stock, ์ฆ‰ ํ•ด๋‹น ๋ฌธ์ œ๋Š”
๋’ค์— ๋กœ๋งˆ ์ˆซ์ž๋ฅผ ๋ถ™ํ˜€์„œ 1, 2, 3, 4, 5 ์ด ๋‹ค์„ฏ์ข…๋ฅ˜๊ฐ€ ์žˆ๋Š”๋ฐ์š”
dp ์—ฐ์Šตํ•˜๊ธฐ์— ์ •๋ง ๊ดœ์ฐฎ์€ ๋ฌธ์ œ๋ผ๊ณ  ์ƒ๊ฐํ•ด์„œ
2๋ฒˆ๋ฌธ์ œ
II๋Š” ํ•œ๋ฒˆ ํ’€์–ด๋ณด์‹œ๊ธธ ์ถ”์ฒœ๋“œ๋ ค์š”!

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 +9 to +11
for price in prices:
max_profit = max(max_profit, price - min_price)
min_price = min(min_price, price)

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.

์‚ฌ์†Œํ•˜์ง€๋งŒ ๋” ์ตœ์ ํ™” ํ•  ์ˆ˜ ์žˆ๋Š” ๋ถ€๋ถ„์€ min, max ์ผ ๊ฑฐ ๊ฐ™์•„์š”. ๊ณ ๋ฏผํ•ด๋ณด์…”๋„ ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

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.

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

  • ํŒจํ„ด: Greedy, Two Pointers
  • ์„ค๋ช…: ๊ฐ€๊ฒฉ์„ ์ˆœํšŒํ•˜๋ฉฐ ํ˜„์žฌ ๊ฐ’๊ณผ ์ด์ „ ์ตœ์ €๊ฐ€์˜ ์ฐจ์ด๋ฅผ ์ตœ๋Œ€ ์ด์ต์œผ๋กœ ์—…๋ฐ์ดํŠธํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ํ•œ ๋ฒˆ์˜ ํŒจ์Šค์—์„œ ์ตœ์  ํ•ด๋ฅผ ์ฐพ๋Š” ๊ทธ๋ฆฌ๋”” ํŒจํ„ด์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค. ๋˜ํ•œ ์ขŒ์šฐ๋กœ ํ•œ ๋ฐฉํ–ฅ์œผ๋กœ๋งŒ ๊ฐ’์„ ๋น„๊ตํ•˜๋ฏ€๋กœ ํˆฌ ํฌ์ธํ„ฐ์˜ ์•„์ด๋””์–ด๊ฐ€ ์ ์šฉ๋ฉ๋‹ˆ๋‹ค.

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

์œ ์ € ๋ถ„์„ ์‹ค์ œ ๋ถ„์„ ๊ฒฐ๊ณผ
Time O(N) O(n) โœ…
Space O(1) O(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.

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

  • ํŒจํ„ด: Greedy, Two Pointers, Hash Map / Hash Set, Divide and Conquer, Dynamic Programming, Binary Search, Monotonic Stack, Trie, Backtracking, DFS, BFS, Union Find, Heap / Priority Queue, Bit Manipulation, Sliding Window
  • ์„ค๋ช…: ๋ฌธ์ž์—ด ์ธ์ฝ”๋”ฉ/๋””์ฝ”๋”ฉ์—์„œ ๊ธธ์ด์™€ ๊ตฌ๋ถ„์ž๋ฅผ ์ด์šฉํ•ด ๊ฐ ๋‹จ์–ด๋ฅผ ๊ตฌ๋ถ„ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ฌธ์ž์—ด์„ ์žฌ๊ตฌ์„ฑํ•œ๋‹ค. ํฌ๋งทํ™”๋œ ์ˆœํšŒ์™€ ์ธ๋ฑ์Šค ๊ด€๋ฆฌ๋กœ ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์„ ์ฐพ์•„๋‚ด๋Š” ๊ณผ์ •์ด ํ•ต์‹ฌ์ด๋ฉฐ, ์ด ๋กœ์ง์€ ๋ฌธ์ž์—ด ์ฒ˜๋ฆฌ์˜ ํƒ์ƒ‰ํ˜• ์ ‘๊ทผ์œผ๋กœ ํ•ด์„๋œ๋‹ค.

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

โ„น๏ธ ์ด ํŒŒ์ผ์—๋Š” 2๊ฐ€์ง€ ํ’€์ด๊ฐ€ ํฌํ•จ๋˜์–ด ์žˆ์–ด ๊ฐ๊ฐ ๋ถ„์„ํ•ฉ๋‹ˆ๋‹ค.

ํ’€์ด 1: Solution.encode โ€” Time: O(n) / Space: O(1)
๋ณต์žก๋„
Time O(n)
Space O(1)

ํ”ผ๋“œ๋ฐฑ: ์ •ํ™•ํžˆ ๊ฐ ๋ฌธ์ž์—ด์˜ ๊ธธ์ด๋ฅผ ์•ž์— ๊ธฐ๋กํ•˜๋ฏ€๋กœ ๊ตฌ๋ถ„์ž ์—†์ด๋„ ๊ฒฝ๊ณ„ ๊ตฌ๋ถ„์ด ๊ฐ€๋Šฅํ•˜๋‹ค.

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

ํ’€์ด 2: Solution.decode โ€” Time: O(n) / Space: O(k)
๋ณต์žก๋„
Time O(n)
Space O(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.

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

  • ํŒจํ„ด: Hash Map / Hash Set, Greedy
  • ์„ค๋ช…: ๋ฌธ์ž์—ด๋“ค์„ ์ •๋ ฌ๋œ ํ˜•ํƒœ๋กœ ํ‚ค๋กœ ์‚ผ์•„ ๊ทธ๋ฃนํ™”ํ•˜๋Š” ์•„์ด๋””์–ด๋กœ ํ•ด์‹œ ๋งต์— ๋ฌถ๋Š” ํŒจํ„ด์ด๋ฉฐ, ๊ฐ ๋‹จ์–ด๋ฅผ ์ •๋ ฌํ•ด ๊ฐ™์€ ํ‚ค๋ฅผ ๊ฐ–๋Š” ๊ฒฝ์šฐ๋ฅผ ๋ชจ์•„ ์ง‘ํ•ฉ์ฒ˜๋Ÿผ ๋ฌถ๋Š” ๋ฐฉ์‹์ด๋‹ค. ๋”ฐ๋ผ์„œ ํ•ด์‹œ ๋งต์„ ํ™œ์šฉํ•˜๋Š” ํŒจํ„ด์ด ํ•ต์‹ฌ์ด๋‹ค.

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

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

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

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

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

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.

4 participants