Skip to content

[parkhojeong] WEEK 04 Solutions#2749

Merged
parkhojeong merged 9 commits into
DaleStudy:mainfrom
parkhojeong:week4
Jul 18, 2026
Merged

[parkhojeong] WEEK 04 Solutions#2749
parkhojeong merged 9 commits into
DaleStudy:mainfrom
parkhojeong:week4

Conversation

@parkhojeong

@parkhojeong parkhojeong commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

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

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
coin-change Medium โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜
find-minimum-in-rotated-sorted-array Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
maximum-depth-of-binary-tree Easy โœ… ์˜๋„ํ•œ ์œ ํ˜•
merge-two-sorted-lists Easy โœ… ์˜๋„ํ•œ ์œ ํ˜•
word-search Medium โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜

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

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

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

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

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

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 1,959 268 2,227 $0.000205
2 2,105 231 2,336 $0.000198
3 2,043 210 2,253 $0.000186
4 2,045 222 2,267 $0.000191
ํ•ฉ๊ณ„ 8,152 931 9,083 $0.000780

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.

ํ˜น์‹œ ์Šฌ๋ผ์ด์‹ฑ์„ ์“ฐ์‹  ์ด์œ ๊ฐ€ ์žˆ์œผ์‹ค๊นŒ์š”?
์Šฌ๋ผ์ด์‹ฑ์€ ๊ทธ ํฌ๊ธฐ๋งŒํผ O(N) ์‹œ๊ฐ„๋ณต์žก๋„๋ผ ๋น ๋ฅด์ง„ ์•Š์„๊ฒƒ ๊ฐ™์•„์„œ์š”,
๋ฌธ์ž์—ด์€ immutable ํ•œ ๊ฐ์ฒด๋ผ์„œ ์ƒˆ๋กœ ๋ณต์‚ฌํ•ด์„œ ์ฃผ๋Š” ๋ฐฉ์‹์œผ๋กœ ์ž‘๋™ํ•˜์ž–์•„์š”

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.

์ด๊ฑฐ ํ’€์ด 1900ms ๋‚˜์˜ค๋Š”๋ฐ 0ms๊นŒ์ง€ ์ค„์ผ์ˆ˜ ์žˆ๋Š”๊ฑฐ ์•„์‹œ๋‚˜์š”? ํ•œ๋ฒˆ ์‹œ๋„ํ•ด๋ณด์‹œ๋Š”๊ฒƒ๋„ ์žฌ๋ฐŒ์œผ์‹ค๊ฑฐ์—์š”!

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.

๋„ˆ๋ฌด ์ž˜ ํ’€์–ด ์ฃผ์…จ๋Š”๋ฐ, ๋‹ค๋งŒ ์กฐ๊ธˆ ์•„์‰ฌ์šด์ ์€ ๋กœ์ง์ด ๋„ˆ๋ฌด ๋ณต์žกํ•ด์„œ ์ฝ”๋“œ ๊ฐ€๋…์„ฑ์ด ๋–จ์–ด์ง€๋Š”๊ฒŒ ์•„๋‹๊นŒ ์‹ถ์–ด์š”
์ฐจ๋ผ๋ฆฌ ๋”๋ฏธ ํ—ค๋“œ๋ฅผ ํ•˜๋‚˜ ์จ์„œ ํ‘ธ์‹œ๋Š”๊ฒŒ ๋” ๋‚˜์„๋“ฏ ํ•˜๋‹ค๋Š” ์ƒ๊ฐ์ด ๋“ญ๋‹ˆ๋‹ค.
์‹ค์ œ๋กœ ๋‹ค๋ฅธ ๋งํฌ๋“œ ๋ฆฌ์ŠคํŠธ ๋ฌธ์ œ๋“ค์„ ํ’€๋‹ค ๋ณด์‹œ๋ฉด ๋”๋ฏธ ํ—ค๋“œ๋ฅผ ์ผ์„๋•Œ ์ฝ”๋“œ๊ฐ€ ๊ฐ„๊ฒฐํ•ด์ง€๋Š” ๊ฒฝ์šฐ๊ฐ€ ๊ฝค ๋งŽ์ด ์žˆ์–ด์š”

@daehyun99
daehyun99 self-requested a review July 17, 2026 14:38
@parkhojeong

parkhojeong commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@alphaorderly
์•ŒํŒŒ๋‹˜ ๋ฆฌ๋ทฐ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ์•„๊นŒ ๋‹ฌ์•„์ฃผ์‹  ๋ฆฌ๋ทฐ์— ๋Œ“๊ธ€์„ ๋‚จ๊ฒผ๋Š”๋ฐ ์ถ”๊ฐ€๋กœ ์ปค๋ฐ‹์„ ํ•˜๋‹ˆ ์ œ๊ฐ€ ๋‚จ๊ธด ์ปค๋ฉ˜ํŠธ๊ฐ€ ์‚ญ์ œ๋˜์—ˆ๊ณ  ๋Œ“๊ธ€ ๋‹ค๋Š” ์ธํ’‹์ฐฝ๋„ ์—†์–ด์ง€๋„ค์š”.

์ฃผ๋กœ ์ปค๋ฉ˜ํŠธ๋ฅผ ๋ด‡ ์ปค๋ฉ˜ํŠธ์— ๋‚จ๊ฒจ์ฃผ์‹œ๋Š” ๊ฑฐ ๊ฐ™์€๋ฐ์š”. ๋ณ„๋„ ์ปค๋ฉ˜ํŠธ๋กœ ๋‚จ๊ฒจ์ฃผ์‹œ๋ฉด ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค. ๋‹ฌ์•„์ฃผ์…จ๋˜ ๊ฒƒ๋“ค์€ ๋ณ„๋„ ์ปค๋ฉ˜ํŠธ๋กœ ๋‹ต๋ณ€๋“œ๋ฆด๊ฒŒ์š”
image

@parkhojeong

parkhojeong commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

@alphaorderly

์ด๊ฑฐ ํ’€์ด 1900ms ๋‚˜์˜ค๋Š”๋ฐ 0ms๊นŒ์ง€ ์ค„์ผ์ˆ˜ ์žˆ๋Š”๊ฑฐ ์•„์‹œ๋‚˜์š”? ํ•œ๋ฒˆ ์‹œ๋„ํ•ด๋ณด์‹œ๋Š”๊ฒƒ๋„ ์žฌ๋ฐŒ์œผ์‹ค๊ฑฐ์—์š”!

c98db17 ๋กœ ์ตœ์ ํ™” ์‹œ๋„ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. ์ธํ’‹ ํŒจํ„ด์— ๋”ฐ๋ฅธ ์ตœ์ ํ™”๋ž‘ ์นด์šดํ„ฐ ๊ธฐ๋ฐ˜์œผ๋กœ ๋„์ค‘์— ์ฒดํฌํ•˜๋Š” ๋ฐฉ์‹์ด ์ด ๋ฌธ์ œ์—์„  ์ ํ•ฉํ•œ ๊ฑฐ ๊ฐ™๋„ค์š”!

์•ŒํŒŒ๋‹˜ ํ‘ธ์…จ๋˜ ํ’€์ด์—๋„ ์ปค๋ฉ˜ํŠธ ํ•˜๋‚˜ ๋‚จ๊ฒจ๋†“์•˜์Šต๋‹ˆ๋‹ค :) #2737 (comment)

@DaleSeo

DaleSeo commented Jul 17, 2026

Copy link
Copy Markdown
Member

@parkhojeong ๋‹˜, ์ฃผ์ฐจ ์„ค์ • ์ข€ ๋ถ€ํƒ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. ์•ˆ ๊ทธ๋Ÿผ ํ†ต๊ณ„์—์„œ ๋ˆ„๋ฝ์ด ๋˜์„œ์š”.

2026-07-17 at 19 42 45

@parkhojeong

Copy link
Copy Markdown
Contributor Author

@parkhojeong ๋‹˜, ์ฃผ์ฐจ ์„ค์ • ์ข€ ๋ถ€ํƒ๋“œ๋ฆฌ๊ฒ ์Šต๋‹ˆ๋‹ค. ์•ˆ ๊ทธ๋Ÿผ ํ†ต๊ณ„์—์„œ ๋ˆ„๋ฝ์ด ๋˜์„œ์š”.

@DaleSeo ์„ค์ •ํ–ˆ์Šต๋‹ˆ๋‹ค. ํ™•์ธ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค.

@daehyun99 daehyun99 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.

์•ˆ๋…•ํ•˜์„ธ์š”.
4์ฃผ์ฐจ ๋ฆฌ๋ทฐ๋ฅผ ๋งก์€ ๊น€๋Œ€ํ˜„์ž…๋‹ˆ๋‹ค!

์ „์ฒด์ ์œผ๋กœ ์ž˜ ํ’€์–ด์ฃผ์‹  ๊ฒƒ ๊ฐ™๋„ค์š”. ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค!

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.

backtrack๊ณผ DIRECTIONS, MARKER๋ฅผ ์‚ฌ์šฉํ•œ ํ’€์ด๊ฐ€ ์ง๊ด€์ ์œผ๋กœ ์ดํ•ด๊ฐ€ ์ž˜ ๋˜์„œ ์ข‹๋„ค์š”!

@parkhojeong parkhojeong Jul 18, 2026

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.

๋Œ€๋ฌธ์ž ์ผ€์ด์‹ฑ์„ ์‚ฌ์šฉํ•˜๋ฉด ๊ฐ€๋…์„ฑ์ด ๊ดœ์ฐฎ๋”๋ผ๊ตฌ์š”. ๋นˆ๋„ ๊ธฐ๋ฐ˜์œผ๋กœ ์ฒดํฌํ•˜๋Š” ๋กœ์ง์€ ์ดˆ๊ธฐ ํ•œ ๋ฒˆ๋งŒ ํ•˜๋ฉด ๋˜์„œ ์ •๋ฆฌํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. 994aca2

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.

์ด๊ฑด ์‚ฌ๋‹ด์ธ๋ฐ

[3, 1] ํ…Œ์ŠคํŠธ ์ผ€์ด์Šค์— ๋Œ€ํ•˜์—ฌ, mid_idx=1์ด ๋˜๊ณ , ์•„๋ž˜์˜ ์ฝ”๋“œ์—์„œ nums[mid_idx + 1:]๊ฐ€ nums[2:]๋กœ ๋˜์–ด์„œ ์ธ๋ฑ์Šค ์—๋Ÿฌ๊ฐ€ ๋‚  ์ค„ ์•Œ์•˜๋Š”๋ฐ, ์•ˆ๋‚˜๋Š”๊ตฐ์š”!
๋ฆฌ๋ทฐํ•  ๋•Œ๋งˆ๋‹ค ์ƒˆ๋กœ์šด ์‚ฌ์‹ค์„ ์•Œ์•„๊ฐ€๊ฒŒ ๋˜๋„ค์š”.

            else:
                nums = nums[mid_idx + 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.

ํŒŒ์ด์ฌ์ด range ๋„˜์–ด๊ฐ€๋Š” ๊ฒฝ์šฐ์—” ๋นˆ ๋ฐฐ์—ด๋กœ ๋˜๋Š” ๊ฒƒ์„ ์‚ฌ์šฉํ•ด๋ณด์•˜์Šต๋‹ˆ๋‹ค. ๊ทผ๋ฐ ์ด ํ’€์ด๋Š” ์Šฌ๋ผ์ด์‹ฑ์ด O(n)์˜ ๋ณต์žก๋„๋ผ ์ตœ์ ํ™” ์ง„ํ–‰ํ•ด๋ดค์Šต๋‹ˆ๋‹ค. 31ba2f4

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.

sys.maxsize๋กœ ์ตœ๋Œ€๊ฐ’์„ ์„ค์ •ํ•  ์ˆ˜ ์žˆ๊ตฐ์š”!
๋งŽ์ด ๋ฐฐ์›Œ๊ฐ‘๋‹ˆ๋‹ค.

@parkhojeong

parkhojeong commented Jul 18, 2026

Copy link
Copy Markdown
Contributor Author

@alphaorderly
์Šฌ๋ผ์ด์‹ฑ์„ ๋ฏธ์ฒ˜ ์ƒ๊ฐ ๋ชปํ–ˆ์—ˆ๋Š”๋ฐ CPython3.14 ๊ธฐ์ค€์œผ๋กœ๋Š” O(k) (k=๊ธธ์ด) ์— ํ•ด๋‹นํ•˜๋Š” ์‹œ๊ฐ„,๊ณต๊ฐ„ ๋ณต์žก๋„๋ฅผ ๊ฐ€์ง€๋„ค์š”. ์ตœ์ ํ™” ์ง„ํ–‰ํ•ด๋ดค์Šต๋‹ˆ๋‹ค! optimize find-minimum-in-rotated-sorted-array

์Šฌ๋ผ์ด์‹ฑ ๊ตฌํ˜„์ฒด ์ง„์ž…์ : _BINARY_SLICE (https://github.com/python/cpython/blob/3.14/Python/bytecodes.c#L847-L863)

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
  • ์„ค๋ช…: ๊ธˆ์•ก๋ณ„ ์ตœ์†Œ ๋™์ „ ๊ฐœ์ˆ˜๋ฅผ ๊ตฌํ•˜๊ธฐ ์œ„ํ•ด ๊ฐ ๊ธˆ์•ก์— ๋Œ€ํ•ด ์ตœ์†Œ ๋น„์šฉ์„ ํŒ๋‹จํ•˜๋Š” DP ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„๋˜์–ด ์žˆ์Šต๋‹ˆ๋‹ค. ๋ถ€๋ถ„ ๋ฌธ์ œ์˜ ํ•ด๋ฅผ ์ด์šฉํ•ด ์ „์ฒด ๋ฌธ์ œ์˜ ํ•ด๋ฅผ ๊ตฌ์„ฑํ•˜๋Š” ์ „ํ˜•์ ์ธ DP ํŒจํ„ด์ž…๋‹ˆ๋‹ค.

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

๋ณต์žก๋„
Time O(amount * len(coins))
Space O(amount)

ํ”ผ๋“œ๋ฐฑ: ์ดˆ๊ธฐ dp ๋ฐฐ์—ด์„ 1/0์œผ๋กœ ๊ตฌ์„ฑํ•˜๋Š” ์ ‘๊ทผ์€ ๊ฐ ๊ธˆ์•ก์— ๋„๋‹ฌ ๊ฐ€๋Šฅํ•œ์ง€ ์—ฌ๋ถ€๋ฅผ ์ €์žฅํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ์ž‘๋™ํ•œ๋‹ค. ๋‹ค๋งŒ ์ดˆ๊ธฐํ™” ๋ฐ ์—…๋ฐ์ดํŠธ ๋กœ์ง์ด ์ž˜๋ชป๋  ๊ฒฝ์šฐ ์ผ๋ถ€ ๊ฒฝ์šฐ์—์„œ -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.

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

  • ํŒจํ„ด: Binary Search
  • ์„ค๋ช…: ์ •๋ ฌ๋œ ๋ฐฐ์—ด์ด ํšŒ์ „๋˜์—ˆ์„ ๋•Œ ์ตœ์†Œ ์›์†Œ๋ฅผ ์ด์ง„ ํƒ์ƒ‰์œผ๋กœ ์ฐพ๋Š” ๋ฐฉ์‹์œผ๋กœ, ๊ตฌ๊ฐ„์„ ์ ˆ๋ฐ˜์œผ๋กœ ์ค„์ด๋ฉฐ ์กฐ๊ฑด์— ๋”ฐ๋ผ lo/hi๋ฅผ ์กฐ์ •ํ•ฉ๋‹ˆ๋‹ค.

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

๋ณต์žก๋„
Time O(log n)
Space 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.

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

  • ํŒจํ„ด: DFS
  • ์„ค๋ช…: ๋ฆฌํ”„๊นŒ์ง€ ํŠธ๋ฆฌ๋ฅผ ๊นŠ์ด ์šฐ์„  ํƒ์ƒ‰ํ•˜์—ฌ ๊ฐ ๊ฐ€์ง€์˜ ๊นŠ์ด๋ฅผ ์žฌ๊ท€์ ์œผ๋กœ ๊ตฌํ•˜๊ณ  ์ตœ๋Œ€ ๊นŠ์ด๋ฅผ ๋ฐ˜ํ™˜ํ•˜๋ฏ€๋กœ DFS ํŒจํ„ด์— ํ•ด๋‹นํ•ฉ๋‹ˆ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ํŠธ๋ฆฌ์˜ ๋ชจ๋“  ๋…ธ๋“œ๋ฅผ ๋ฐฉ๋ฌธํ•˜๋ฉฐ ๊ฐ ์žฌ๊ท€ ํ˜ธ์ถœ์ด ๊นŠ์ด๋ฅผ ์ฆ๊ฐ€์‹œํ‚ค๋Š” ์ „ํ˜•์ ์ธ DFS ๋ฐฉ์‹์ด๋‹ค.

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

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

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, Linked List
  • ์„ค๋ช…: ๋‘ ๊ฐœ์˜ ์ •๋ ฌ๋œ ์—ฐ๊ฒฐ๋ฆฌ์ŠคํŠธ๋ฅผ ํ•œ ๋ฆฌ์ŠคํŠธ๋กœ ๋ณ‘ํ•ฉํ•˜๋Š” ๊ณผ์ •์—์„œ ํฌ์ธํ„ฐ ๋‘ ๊ฐœ๋กœ ์ˆœํšŒํ•˜๋ฉฐ ๊ฐ’์„ ๋น„๊ตํ•˜์—ฌ ์ˆœ์„œ๋ฅผ ๋งž์ถ”๋Š” ํŒจํ„ด์ด๋‹ค. ๋‚จ์€ ๋ถ€๋ถ„์„ ํ•œ๊บผ๋ฒˆ์— ๋ถ™์ด๋Š” ๋ฐฉ์‹์ด ํŠน์ง•์ด๋‹ค.

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

๋ณต์žก๋„
Time O(n + m)
Space 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.

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

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

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

๋ณต์žก๋„
Time O(N * 4^L)
Space O(L)

ํ”ผ๋“œ๋ฐฑ: ์‚ฌ์ „ ๊ฒ€์‚ฌ๋กœ ๋ฌธ์ž ๋นˆ๋„์™€ ๋ฐฉํ–ฅ ํƒ์ƒ‰์„ ์ตœ์ ํ™”ํ•˜๋ ค๊ณ  ์‹œ๋„ํ•œ๋‹ค. ๋ฐฑํŠธ๋ž˜ํ‚น ์‹œ ์ค‘๋ณต ๋ฐฉ๋ฌธ ์ œ์–ด๊ฐ€ ํ•ต์‹ฌ์ด๋‹ค.

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

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

@parkhojeong

Copy link
Copy Markdown
Contributor Author

์•ˆ๋…•ํ•˜์„ธ์š”. 4์ฃผ์ฐจ ๋ฆฌ๋ทฐ๋ฅผ ๋งก์€ ๊น€๋Œ€ํ˜„์ž…๋‹ˆ๋‹ค!

์ „์ฒด์ ์œผ๋กœ ์ž˜ ํ’€์–ด์ฃผ์‹  ๊ฒƒ ๊ฐ™๋„ค์š”. ๊ณ ์ƒํ•˜์…จ์Šต๋‹ˆ๋‹ค!

๋ฆฌ๋ทฐ ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค. ๋Œ€ํ˜„๋‹˜ ๋ฆฌ๋ทฐ ๋‚จ๊ฒจ์ฃผ์‹  ์ดํ›„์— ๋ช‡๊ฐ€์ง€ ์ตœ์ ํ™”ํ•˜์—ฌ์„œ ์ปค๋ฉ˜ํŠธ ๋‚จ๊ฒจ๋‘์—ˆ์Šต๋‹ˆ๋‹ค

@parkhojeong
parkhojeong merged commit 5bcbd05 into DaleStudy:main Jul 18, 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.

4 participants