Skip to content

[dahyeong-yun] WEEK 02 solutions#2684

Open
dahyeong-yun wants to merge 10 commits into
DaleStudy:mainfrom
dahyeong-yun:main
Open

[dahyeong-yun] WEEK 02 solutions#2684
dahyeong-yun wants to merge 10 commits into
DaleStudy:mainfrom
dahyeong-yun:main

Conversation

@dahyeong-yun

@dahyeong-yun dahyeong-yun commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

๐Ÿ“Š dahyeong-yun ๋‹˜์˜ ํ•™์Šต ํ˜„ํ™ฉ

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
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 577 67 644 $0.000056
2 577 37 614 $0.000044
3 3,438 198 3,636 $0.000251
4 3,437 185 3,622 $0.000246
5 3,435 223 3,658 $0.000261
6 3,378 185 3,563 $0.000243
ํ•ฉ๊ณ„ 14,842 895 15,737 $0.001100

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

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค! ๋ช‡ ๊ฐ€์ง€ ์ปค๋ฉ˜ํŠธ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค :)
validate-binary-search-tree๊ฐ€ ์ž˜๋ชป ์˜ฌ๋ผ์™€ ์žˆ์–ด์„œ request changes ๋‚จ๊น๋‹ˆ๋‹ค!

Comment on lines +24 to +35
if(n == 1) return 1;
if(n == 2) return 2;

int[] steps = new int[n+1];
steps[1] = 1;
steps[2] = 2;

for(int i=3; i<=n; i++) {
steps[i] = steps[i-1] + steps[i-2];
}
return steps[n];
}

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.

๊ฐ€๋…์„ฑ ์ข‹์€ ์ฝ”๋“œ์ธ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Comment on lines +19 to +27
public boolean isAnagram(String s, String t) {
char[] arrayS = s.toCharArray();
char[] arrayT = t.toCharArray();

Arrays.sort(arrayS);
Arrays.sort(arrayT);

return Arrays.equals(arrayS, arrayT);
}

@parkhojeong parkhojeong Jul 4, 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.

n log(n) ์˜ ๋ณต์žก๋„๋ฅผ ๋นˆ๋„ ์นด์šดํŠธ๋ฅผ ์ด์šฉํ•ด ๊ฐœ์„ ํ•ด๋ณผ ์ˆ˜๋„ ์žˆ์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

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.

๋นˆ๋„ ์นด์šดํŠธ๋ฅผ ์ด์šฉํ•ด์„œ ๊ฐœ์„ ํ•œ๋‹ค๋Š” ์˜๋ฏธ์‹ ๊ฑฐ์ฃ ? ๋ง์”€์ฃผ์‹ ๋Œ€๋กœ ๋ฌธ์ž์—ด์˜ Character ๋‹จ์œ„๋กœ ๋นˆ๋„ ์นด์šดํŠธ ํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ๊ฒ ๋„ค์š”.

Comment thread validate-binary-search-tree/dahyeong-yun.java Outdated
Comment on lines +24 to +39
int prefix = 1;
int suffix = 1;

int len = nums.length;
int[] answer = new int[len];

answer[0] = 1;
for(int i = 1; i < len; i++) {
answer[i] = prefix * nums[i-1];
prefix *= nums[i-1];
}

for(int i = len-1; i >= 0; i--) {
answer[i] = answer[i] * suffix;
suffix *= nums[i];
}

@parkhojeong parkhojeong Jul 4, 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.

prefix, suffix์˜ ๋ณ€์ˆ˜๋ช…์ด ๊ฐ’์ด ์ง๊ด€์ ์ด์ง€๋Š” ์•Š์•„์„œ ๊ฐ’์˜ ์˜๋ฏธ๋ฅผ ๋‹ด์œผ๋ฉด ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!
์ฐธ๊ณ ๋กœ answer์„ ์ด์šฉํ•ด์„œ prefix ์ œ๊ฑฐํ•˜๋Š” ๊ฒƒ๋„ ๊ฐ€๋Šฅํ•  ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค~

Comment thread 3sum/dahyeong-yun.java
Comment on lines +30 to +34
for(int i=0; i < nums.length - 2; i++) {
if (i > 0 && nums[i] == nums[i - 1]) {
continue;
}

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.

nums[i] > 0 ์ธ ๋ถ€๋ถ„๋ถ€ํ„ฐ๋Š” ์–‘์ˆ˜ + ์–‘์ˆ˜ + ์–‘์ˆ˜ ๊ฐ€ ๋˜์„œ ์ด ์กฐ๊ฑด๋„ ๊ณ ๋ คํ•ด๋ณด์‹œ๋ฉด ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!
ex: [-2, -1, 0, 1, 2, 3, 4, 5, 6, 7]

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.

Suggested change
for(int i=0; i < nums.length - 2; i++) {
if (i > 0 && nums[i] == nums[i - 1]) {
continue;
}
for(int i=0; i < nums.length - 2; i++) {
if (nums[i] > 0) {
break;
}
if (i > 0 && nums[i] == nums[i - 1]) {
continue;
}

์ด๋Ÿฐ ์‹์œผ๋กœ ์กฐ๊ธฐ ์ข…๋ฃŒ๋ฅผ ํ•  ์ˆ˜ ์žˆ๊ฒ ๋„ค์š”

Comment thread 3sum/dahyeong-yun.java
Comment on lines +38 to +47
while(left < right) {
if(nums[i] + nums[left] + nums[right] == 0) {
List<Integer> triple = List.of(nums[i], nums[left], nums[right]);
answer.add(triple);
while(left+1 < right && nums[left] == nums[left+1]) left++;
while(right > 0 && nums[right] == nums[right-1]) right--;
left++;
right--;
} else if(nums[i] + nums[left] + nums[right] > 0) right--;
else left++;

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.

while(left+1 < right ..), while(right > 0 ..) ์—์„œ right > 0๋„ left์ฒ˜๋Ÿผ ํ‰๊ฐ€ํ•˜๋Š” ๊ฒƒ์ด ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

Comment thread 3sum/dahyeong-yun.java

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, Sorting, Hash Map / Hash Set
  • ์„ค๋ช…: 3sum ๋ฌธ์ œ์—์„œ ๋จผ์ € ๋ฐฐ์—ด์„ ์ •๋ ฌํ•œ ๋’ค ๊ณ ์ • ์ˆ˜์™€ ๋‘ ํฌ์ธํ„ฐ๋กœ ๋‚˜๋จธ์ง€ ๋‘ ์ˆ˜๋ฅผ ์ฐพ๋Š” ๋ฐฉ์‹์œผ๋กœ ์ค‘๋ณต ์ œ๊ฑฐ์™€ ๋ชฉํ‘œ ํ•ฉ 0 ๋‹ฌ์„ฑ์„ ์ˆ˜ํ–‰ํ•ฉ๋‹ˆ๋‹ค. ๊ณต๊ฐ„์€ ์ƒ์ˆ˜์— ๊ฐ€๊น๊ณ  ์‹œ๊ฐ„๋ณต์žก๋„๋Š” O(n^2)์ž…๋‹ˆ๋‹ค.

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

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

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

  • ํŒจํ„ด: Dynamic Programming
  • ์„ค๋ช…: ๊ณ„๋‹จ ์ˆ˜ ๋ฌธ์ œ๋ฅผ ํ”ผ๋ณด๋‚˜์น˜ํ˜• ์ ํ™”์‹์œผ๋กœ ํ•ด๊ฒฐํ•˜๋ฉฐ, ์ด์ „ ๋‹จ๊ณ„์˜ ๊ฒฐ๊ณผ๋ฅผ ์ด์šฉํ•ด ํ˜„์žฌ ๊ฐ’์„ ๊ตฌํ•˜๋Š” ์ „ํ˜•์ ์ธ DP ํŒจํ„ด์ด๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ์ดˆ๊ธฐ ๊ฒฝ๊ณ„์กฐ๊ฑด์„ ๋ช…ํ™•ํžˆ ๋‘๊ณ  ์ˆœ์ฐจ์ ์œผ๋กœ ์ฑ„์›Œ ๋‚˜๊ฐ€๋Š” DP ํ’€์ด์ž…๋‹ˆ๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ๋ฉ”๋ชจ๋ฆฌ ์‚ฌ์šฉ์„ ์ค„์ด๋ ค๋ฉด ๋‘ ๋ณ€์ˆ˜๋กœ ๋กค๋ง ๋ฐฐ์—ด๋กœ ๊ตฌํ˜„ํ•˜๋Š” ๋Œ€์•ˆ์„ ๊ณ ๋ คํ•ด๋ณผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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, Dynamic Programming, Hash Map / Hash Set
  • ์„ค๋ช…: ๋‘ ํŒจํ„ด์˜ ํ•ต์‹ฌ ์•„์ด๋””์–ด๋Š” ์™ผ์ชฝ/์˜ค๋ฅธ์ชฝ ๋ˆ„์  ๊ณฑ์„ ๊ตฌํ•ด ๊ฐ ์›์†Œ๋ฅผ ์ œ์™ธํ•œ ๊ณฑ์„ ๊ตฌํ•˜๋Š” ๋ฐฉ์‹์ด๋‹ค. ๋ฐฐ์—ด์„ ๋‘ ๋ฒˆ ์ˆœํšŒํ•˜๋ฉฐ ์„ ํ–‰๊ณผ ํ›„ํ–‰ ๊ฐ’์„ ์ถ•์ ํ•˜๋Š” ๋ฐฉ์‹์€ ์ตœ์ ํ•ด๋ฅผ ์–ป๋Š” ๋‹ค์ธต ๋ˆ„์  ๊ณ„์‚ฐ์œผ๋กœ ๋ถ„๋ฅ˜ํ•  ์ˆ˜ ์žˆ๋‹ค. ๋˜ํ•œ ๋ฌธ์ œ์˜ ๋ชฉํ‘œ๋Š” ๊ฐ ์›์†Œ๋ฅผ ์ œ์™ธํ•œ ๊ณฑ์„ ๊ตฌํ•˜๋Š” ๊ตฌ์กฐ๋กœ DP์˜ ๋ˆ„์  ๊ด€๊ณ„๋ฅผ ํ™œ์šฉํ•˜๋Š” ์˜ˆ์ด๋‹ค.

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

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

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

  • ํŒจํ„ด: Time Complexity Analysis Pattern?
  • ์„ค๋ช…: ์ œ์‹œ๋œ ์ฝ”๋“œ๋Š” ๋‘ ๋ฌธ์ž์—ด์„ ์ •๋ ฌํ•œ ๋’ค ๋น„๊ตํ•˜๋Š” ๋ฐฉ๋ฒ•์œผ๋กœ ์• ๋„ˆ๊ทธ๋žจ ์—ฌ๋ถ€๋ฅผ ํŒ๋ณ„ํ•œ๋‹ค. ์ด๋Š” ๋‘ ๋ฐฐ์—ด ์ •๋ ฌ ํ›„ ๋น„๊ตํ•˜๋Š” ๊ธฐ๋ณธ์ ์ธ ์•„์ด๋””์–ด์ด๋ฉฐ, ํŒจํ„ด์œผ๋กœ๋Š” ์ •๋ ฌ(Sort) ์ž์ฒด๋ฅผ ์ด์šฉํ•œ ํ•ด๊ฒฐ๊ณผ ๊ทธ์— ๋”ฐ๋ฅธ ๋น„๊ต๋ฅผ ํฌํ•จํ•œ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ๋ฌธ์ž ์ •๋ ฌ์œผ๋กœ ์• ๋„ˆ๊ทธ๋žจ ์—ฌ๋ถ€๋ฅผ ํŒ๋‹จํ•˜๋Š” ์ง๊ด€์ ์ธ ์ ‘๊ทผ์ž…๋‹ˆ๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ์ถ”๊ฐ€๋กœ ํ•ด์‹œ๋งต์„ ์ด์šฉํ•ด ์„ ํ˜• ์‹œ๊ฐ„์œผ๋กœ ํ’€์ดํ•˜๋Š” ๋ฐฉ๋ฒ•๋„ ์žˆ์Šต๋‹ˆ๋‹ค.

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, Divide and Conquer, Depth-First Search
  • ์„ค๋ช…: BST ์œ ํšจ์„ฑ ๊ฒ€์‚ฌ์—์„œ ๊ฐ ๋…ธ๋“œ์— ๋Œ€ํ•ด ๋ฒ”์œ„๋ฅผ ์žฌ๊ท€์ ์œผ๋กœ ์ขํ˜€ ํ™•์ธํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ๋‘ ์ž์‹์œผ๋กœ ๋ถ„ํ• ํ•˜๋ฉฐ ๋ฌธ์ œ๋ฅผ ํ•ด๊ฒฐํ•œ๋‹ค. ์žฌ๊ท€ DFS๋ฅผ ํ™œ์šฉํ•˜๊ณ  ๋ฒ”์œ„๋ฅผ ๊ฐ๊ฐ ์™ผ์ชฝ/์˜ค๋ฅธ์ชฝ์— ๋Œ€ํ•ด ์ขํ˜€ ๊ฐ€๋Š” ๋ฐฉ์‹์€ divide and conquer์™€ DFS์˜ ์กฐํ•ฉ์œผ๋กœ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ์ „์œ„์ˆœํšŒ ๋ฐฉ์‹์œผ๋กœ ๊ฐ ๋…ธ๋“œ์˜ ๋ฒ”์œ„๋ฅผ ์ž์‹ ๋…ธ๋“œ์— ์ „๋‹ฌํ•˜์—ฌ BST ์กฐ๊ฑด์„ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ์Šคํƒ ๊ธฐ๋ฐ˜ ์ˆœํšŒ๋กœ ์žฌ๊ท€ ๊นŠ์ด๋ฅผ ์ œ๊ฑฐํ•ด ๊ณต๊ฐ„์„ ์ตœ์ ํ™”ํ•  ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

@dahyeong-yun dahyeong-yun requested a review from parkhojeong July 4, 2026 08:28
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