Skip to content

[dolphinflow86] WEEK 02 Solutions#2677

Merged
dolphinflow86 merged 7 commits into
DaleStudy:mainfrom
dolphinflow86:main
Jul 3, 2026
Merged

[dolphinflow86] WEEK 02 Solutions#2677
dolphinflow86 merged 7 commits into
DaleStudy:mainfrom
dolphinflow86:main

Conversation

@dolphinflow86

@dolphinflow86 dolphinflow86 commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

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

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
3sum Medium โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜
climbing-stairs Easy โœ… ์˜๋„ํ•œ ์œ ํ˜•
product-of-array-except-self Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
valid-anagram Easy โœ… ์˜๋„ํ•œ ์œ ํ˜•
validate-binary-search-tree Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•

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

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

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

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

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

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 291 42 333 $0.000031
2 467 37 504 $0.000038
3 880 74 954 $0.000074
4 1,273 166 1,439 $0.000130
5 1,695 230 1,925 $0.000177
6 2,124 229 2,353 $0.000198
7 2,124 249 2,373 $0.000206
ํ•ฉ๊ณ„ 8,854 1,027 9,881 $0.000854

@github-actions github-actions Bot added the py label Jun 28, 2026
@dolphinflow86 dolphinflow86 changed the title valid anagram solution 1 [dolphinflow86] WEEK 02 Solutions Jun 28, 2026
@JeonJe JeonJe self-requested a review June 28, 2026 15:04
@JinuCheon JinuCheon self-requested a review June 29, 2026 13:54
Comment thread 3sum/dolphinflow86.py

@alphaorderly alphaorderly Jul 1, 2026

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.

์˜ค ์ด๋Ÿฌ๋ฉด ์™ผ์ชฝ ํฌ์ธํ„ฐ๋ฅผ ํ•˜๋‚˜ ๋‘๊ณ 
์˜ค๋ฅธ์ชฝ ๋ถ€๋ถ„๋งŒ ๋ถ€๋ถ„๋ฌธ์ œ์ฒ˜๋Ÿผ Two sum ๋ฌธ์ œ๋กœ ํ‘ธ์‹ ๊ฑฐ๋ฆฌ๊ณ  ๋ณด๋ฉด ๋ ๊นŒ์š”?
์ด๋Ÿฐ ๋ฐฉ๋ฒ•๋„ ์žˆ๋‹ค๋‹ˆ ๋„ˆ๋ฌด ์‹ ๊ธฐํ•˜๋„ค์š”! ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค!

# 1) Sort input strings and check if those are the same.
# TC: O(NlogN) where N is the size of string s and t due to sorting
# SC: O(N) where N is the length of string s and t to store sorted list.
class Solution:

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.

์•ˆ๋…•ํ•˜์„ธ์š”! ์ด๋ฒˆ์— ์ฝ”๋“œ๋ฆฌ๋ทฐ๋ฅผ ๋งก๊ฒŒ ๋œ ์ด์ „์ œ์ž…๋‹ˆ๋‹ค. ์ž˜๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

solve ์ฝ”๋“œ ๋„ˆ๋ฌด ๊น”๋”ํ•˜๊ฒŒ ์ž˜ ์ž‘์„ฑํ•˜์…จ๋„ค์š”!!

์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๋” ๋‚ฎ์ถฐ์•ผํ•œ๋‹ค๋Š” ์ œ์•ฝ์กฐ๊ฑด์ด ์žˆ๋‹ค๋ฉด, ์ •๋ ฌ์ด ์•„๋‹Œ ์–ด๋–ค ๋‹ค๋ฅธ ๋ฐฉ์‹์œผ๋กœ ๋ฌธ์ œ ํ’€์ด ์ ‘๊ทผํ•˜์‹ค ์ง€ ๊ถ๊ธˆํ•ฉ๋‹ˆ๋‹ค!

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.

@JeonJe ์•ˆ๋…•ํ•˜์„ธ์š” ์ „์ œ๋‹˜ :) ์ €๋„ ์ž˜ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.

์ด ๋ฌธ์ œ๋Š” ์‹œ๊ฐ„๋ณต์žก๋„๋ฅผ ๋” ๋‚ฎ์ถ˜๋‹ค๋ฉด ์•„๋ž˜์˜ 2๋ฒˆ์งธ ๋ฐฉ๋ฒ•์œผ๋กœ ํ‘ผ ํ•ด์‹œ๋งต ์‚ฌ์šฉํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์ ‘๊ทผํ•˜์—ฌ ํ’€ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

๋‹ค๋งŒ 2๋ฒˆ ์†”๋ฃจ์…˜์—์„œ๋„ s์™€ t๊ฐ€ ์˜๋ฌธ ์†Œ๋ฌธ์ž ์ œํ•œ์ด ์žˆ์–ด์„œ ํ•ด์‹œ๋งต ๋Œ€์‹ ์— 26ํฌ๊ธฐ์˜ ๊ณ ์ •๋ฐฐ์—ด๋กœ ๋ณ€๊ฒฝํ•ด์„œ ํ‘ธ๋Š” ๊ฒƒ์œผ๋กœ ์กฐ๊ธˆ

๋” ์ตœ์ ํ™”๋ฅผ ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”.

# 1) Recursion with memoization.
# TC: O(N) where N is the given natural number.
# SC: O(N) where N is the given natural number.
class Solution:

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.

@JeonJe ์ด ๋ฌธ์ œ๋Š” ๊ฐ ์Šคํƒญ๋งˆ๋‹ค ํ–‰ํ•  ์ˆ˜ ์žˆ๋Š” ํ–‰๋™์ด 1์นธ ์•„๋‹ˆ๋ฉด 2์นธ์˜ ์ ํ”„๋ผ๊ณ  ์ƒ๊ฐํ–ˆ๊ณ  ํ”ผ๋ณด๋‚˜์น˜๋‚˜ house robber ๋ฌธ์ œ์—์„œ ํ’€์—ˆ๋˜ ํ’€์ด๋ฅผ ์ ์šฉํ•ด๋ณผ ์ˆ˜ ์žˆ๊ฒ ๋‹ค๋ผ๋Š” ์ƒ๊ฐ์ด ๋“ค์–ด์„œ ์žฌ๊ท€๋กœ ์ ‘๊ทผํ–ˆ์Šต๋‹ˆ๋‹ค. ์‹คํ–‰ ํ๋ฆ„์€ 1์ธต๋ถ€ํ„ฐ n์ธต๊นŒ์ง€ ์žฌ๊ท€์ ์œผ๋กœ ์˜ฌ๋ผ๊ฐ€๋˜, n์ธต์—์„œ ๋ฒ ์ด์Šค์ผ€์ด์Šค์— ๊ฑธ๋ ค ๋‚ด๋ ค์˜ค๋ฉด์„œ memo๋ฅผ ์ฑ„์šฐ๋Š”์‹์œผ๋กœ ๊ตฌํ˜„ํ•˜์˜€๊ณ , ์ €๋„ ํ—ท๊ฐˆ๋ ค์„œ ๊ฒฐ์ •ํŠธ๋ฆฌ ๊ทธ๋ ค๋ณด๋ฉด์„œ ๋‹ค์‹œ ๋ฆฌ๋งˆ์ธ๋“œ ํ–ˆ๋„ค์š” :)

Comment thread 3sum/dolphinflow86.py

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.

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

  • ํŒจํ„ด: Two Pointers, Hash Map / Hash Set, Greedy, Sorting
  • ์„ค๋ช…: ์ฝ”๋“œ๋Š” ์ •๋ ฌ ํ›„ ํ•˜๋‚˜์˜ ์›์†Œ๋ฅผ ๊ณ ์ •ํ•˜๊ณ  ๋‚˜๋จธ์ง€ ๋‘ ์ˆ˜๋ฅผ ํ•ฉ์œผ๋กœ ์ฐพ๋Š” ๋ฐฉ์‹์œผ๋กœ ํƒ์ƒ‰ํ•œ๋‹ค. ๋‚ด๋ถ€์—์„œ Hash Map์œผ๋กœ ์ด์ „ ๊ฐ’ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•ด ์ค‘๋ณต ์กฐํ•ฉ ์ œ๊ฑฐ๋ฅผ ์ˆ˜ํ–‰ํ•œ๋‹ค.

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

์œ ์ € ๋ถ„์„ ์‹ค์ œ ๋ถ„์„ ๊ฒฐ๊ณผ
Time O(N^2) O(n^2) โœ…
Space O(N) O(n) โœ…

ํ”ผ๋“œ๋ฐฑ: ์ •๋ ฌ ํ›„ ์ค‘๋ณต ์ œ๊ฑฐ๋ฅผ ์œ„ํ•ด i ์ธ๋ฑ์Šค์˜ ์ด์ „ ๊ฐ’๊ณผ ๋น„๊ตํ•˜๊ณ , ๋‚ด๋ถ€์—์„œ ํ•ด์‹œ๋งต์œผ๋กœ ๋ณด์กฐ ํƒ์ƒ‰์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค.

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

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, Memoization, Divide and Conquer
  • ์„ค๋ช…: ์žฌ๊ท€์™€ ๋ฉ”๋ชจ์ด์ œ์ด์…˜์œผ๋กœ ์ค‘๋ณต ๋ถ€๋ถ„ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•˜๋Š” DP ์„ฑ๊ฒฉ์˜ ํ’€์ด์ž…๋‹ˆ๋‹ค. ๋น„์Šทํ•œ ์ƒํƒœ๋ฅผ ์žฌ์‚ฌ์šฉํ•ด ํŠธ๋ฆฌ ๊ตฌ์กฐ์˜ ๋ถ„ํ• ์„ ์ค„์ด๊ณ , ์ตœ์ข…์ ์œผ๋กœ ํ”ผ๋ณด๋‚˜์น˜์™€ ์œ ์‚ฌํ•œ ์ ํ™”์‹์œผ๋กœ ํ•ด๊ฒฐํ•ฉ๋‹ˆ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ์ƒํ–ฅ์‹ ๋™์  ํ”„๋กœ๊ทธ๋ž˜๋ฐ์„ ์žฌ๊ท€๋กœ ๊ตฌํ˜„ํ•ด ์ค‘๋ณต์„ ์ œ๊ฑฐํ–ˆ์Šต๋‹ˆ๋‹ค. ๋ฉ”๋ชจ์ด์ œ์ด์…˜์œผ๋กœ ๋ถˆํ•„์š”ํ•œ ์žฌํ˜ธ์ถœ ๊ฐ์†Œ.

๊ฐœ์„  ์ œ์•ˆ: ๋ฃจํ‹ด์„ ๋ฐ˜๋ณต๋ฌธ์œผ๋กœ ๋ณ€ํ™˜ํ•˜๋ฉด ํ˜ธ์ถœ ์Šคํƒ ์‚ฌ์šฉ์„ ํ”ผํ•˜๊ณ  ์ƒ์ˆ˜ ๊ณต๊ฐ„์œผ๋กœ ๊ฐœ์„ ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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

@dolphinflow86 dolphinflow86 merged commit 4b99484 into DaleStudy:main Jul 3, 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