Skip to content

[seueooo] WEEK 03 Solutions#2725

Merged
seueooo merged 9 commits into
DaleStudy:mainfrom
seueooo:main
Jul 11, 2026
Merged

[seueooo] WEEK 03 Solutions#2725
seueooo merged 9 commits into
DaleStudy:mainfrom
seueooo:main

Conversation

@seueooo

@seueooo seueooo commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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

Week2

Week2์— ๋ชป ํ‘ผ ๋ฌธ์ œ๋„ ๊ฐ™์ด ์ œ์ถœํ•ฉ๋‹ˆ๋‹ค.

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

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

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
3sum Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
combination-sum Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
decode-ways Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
maximum-subarray Medium โœ… ์˜๋„ํ•œ ์œ ํ˜•
number-of-1-bits Easy โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜
valid-palindrome Easy โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜
validate-binary-search-tree Medium โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜

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

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

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

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

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

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 2,819 359 3,178 $0.000285
2 2,800 305 3,105 $0.000262
3 2,793 348 3,141 $0.000279
ํ•ฉ๊ณ„ 8,412 1,012 9,424 $0.000825

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

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค~! ์ฝ”๋“œ๊ฐ€ ๊ฐ„๊ฒฐํ•˜๊ณ  ํ’€์ด๋„ ์ตœ์ ํ™”๊ฐ€ ๋งŽ์ด ๋˜์–ด์žˆ์–ด์„œ ์ข‹์•˜์Šต๋‹ˆ๋‹ค :)
๋ช‡ ๊ฐ€์ง€ ์ปค๋ฉ˜ํŠธ ๋‚จ๊ฒจ๋ณด์•˜์Šต๋‹ˆ๋‹ค.

Comment thread decode-ways/seueooo.js
Comment thread maximum-subarray/seueooo.js Outdated
Comment on lines +9 to +16
let dp = new Array(nums.length).fill(0);

dp[0] = nums[0];
for (let i = 1; i < nums.length; i++) {
dp[i] = Math.max(dp[i - 1] + nums[i], nums[i]);
}

return Math.max(...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.

kadane ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๋ž€๊ฑธ ์“ฐ์‹  ๊ฑฐ ๊ฐ™์€๋ฐ ํ˜น์‹œ ์–ด๋–ค ๋ฐฉ๋ฒ•์ธ์ง€ ์„ค๋ช… ๋ถ€ํƒ๋“œ๋ ค๋„ ๋ ๊นŒ์š”?

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.

์˜ค ์ฒ˜์Œ ๋“ค์–ด๋ณด๋Š”๋ฐ ์ œ๊ฐ€ ๊ตฌํ˜„ํ•œ ๋ฐฉ์‹์ด kadane ์•Œ๊ณ ๋ฆฌ์ฆ˜์ด๊ตฐ์š”..!
ํ˜„์žฌ ๊ฐ’ nums[i]๋ฅผ ์ด์ „ ์—ฐ์†ํ•ฉ์— ์ด์–ด ๋ถ™์ผ์ง€, ์•„๋‹ˆ๋ฉด nums[i]๋ถ€ํ„ฐ ์ƒˆ๋กœ ์‹œ์ž‘ํ• ์ง€๋ฅผ ๋น„๊ตํ•ด์„œ ์ตœ๋Œ€ ์—ฐ์† ๋ถ€๋ถ„ํ•ฉ์„ ๊ฐฑ์‹ ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๊ตฌํ˜„ํ–ˆ์Šต๋‹ˆ๋‹ค :)

Comment thread valid-palindrome/seueooo.js Outdated
Comment on lines +17 to +26
let prev = -Infinity;

const inOrder = (node) => {
if (!node) return true;
if (!inOrder(node.left)) return false;
if (node.val <= prev) return false;
prev = node.val;
return inOrder(node.right);
};
return inOrder(root);

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.

inOrder ๋ฐฉ์‹์œผ๋กœ ํ’€์–ด์ฃผ์…จ๊ตฐ์š”! ์ „์—ญ๋ณ€์ˆ˜ prev๋ฅผ ์‚ฌ์šฉํ•˜๊ณ  ์žˆ๋Š”๋ฐ ์ˆœ์ˆ˜ ํ•จ์ˆ˜ ํ˜•ํƒœ๋กœ ํ’€์–ด๋ณด์…”๋„ ์ข‹์„ ๊ฑฐ ๊ฐ™์•„์š”!

Comment on lines +6 to +9
N = candidates.length
T = target
M = candidates ์ค‘ ์ตœ์†Ÿ๊ฐ’

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.

์š” ๋ถ€๋ถ„์€ ์ฝ”๋“œ๋ž‘์€ ๊ด€๋ จ ์—†๊ณ  ์‹œ๊ฐ„๋ณต์žก๋„ ๊ณ„์‚ฐ์—์„œ T / M์˜ ์˜๋ฏธ๋ฅผ ์„ค๋ช…ํ•˜๋ ค๊ณ  ๋‘” ์ฃผ์„์ด์—์š” !

Comment thread 3sum/seueooo.js
Comment on lines +14 to +34
for (let i = 0; i < n - 2; i++) {
let l = i + 1;
let h = n - 1;
if (nums[i] > 0) break;
// ์ค‘๋ณต ์ œ๊ฑฐ
if (i > 0 && nums[i] === nums[i - 1]) continue;

while (l < h) {
const sum = nums[i] + nums[l] + nums[h];
if (sum > 0) {
h--;
} else if (sum < 0) {
l++;
} else {
answer.push([nums[i], nums[l], nums[h]]);
while (l < h && nums[l] === nums[l + 1]) l++;
while (l < h && nums[h] === nums[h - 1]) h--;
l++;
h--;
}
}

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 +8 to +14
var hammingWeight = function (n) {
let count = 0;
while (n > 0) {
if (n % 2 === 1) count++;
n = Math.floor(n / 2);
}
return count;

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

์‚ฌ์†Œํ•œ ๋ถ€๋ถ„์ด๊ธด ํ•œ๋ฐ ์š”๋Ÿฐ ์Šคํƒ€์ผ๋„ ํ•œ ๋ฒˆ ๊ณ ๋ คํ•ด๋ณด์…”๋„ ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!

  • python์—๋Š” n // 2 ์ฒ˜๋Ÿผ ๊น”๋”ํ•˜๊ฒŒ ํ‘œํ˜„์ด ๋˜๋Š”๋ฐ js ๋Š” ๋น„์Šทํ•œ ์—ฐ์‚ฐ์ด n >> 1 ์ผ ๊ฑฐ ๊ฐ™๋„ค์š”. ํ•œ ๋ฒˆ ๊ณ ๋ คํ•ด๋ณด์…”๋„ ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค :)
  • count ๋ถ€๋ถ„์€ n % 2 ์˜ ๊ฒฐ๊ณผ๊ฐ€ 0, 1์ด์–ด์„œ count += n % 2๋กœ ์จ๋ณผ ์ˆ˜๋„ ์žˆ์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค!
Suggested change
var hammingWeight = function (n) {
let count = 0;
while (n > 0) {
if (n % 2 === 1) count++;
n = Math.floor(n / 2);
}
return count;
var hammingWeight = function (n) {
let count = 0;
while (n > 0) {
count += n % 2;
n >>= 1;
}
return count;

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.

์‹œํ”„ํŠธ ์—ฐ์‚ฐ์ž๋ฅผ ๊ฑฐ์˜ ์‚ฌ์šฉํ•ด๋ณด์ง€ ์•Š์•„์„œ ์ž˜ ๋ชฐ๋ž๋Š”๋ฐ ์ข‹์€ ์ •๋ณด ์•Œ์•„๊ฐ‘๋‹ˆ๋‹ค :)

@JAEKWANG97 JAEKWANG97 self-requested a review July 10, 2026 21:31

for (let i = start; i < candidates.length; i++) {
path.push(candidates[i]);
dfs(i, path, sum + candidates[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.

start๋ฅผ ๋„˜๊ฒจ ์ค‘๋ณต ์กฐํ•ฉ์„ ๋ง‰๊ณ , ์žฌ๊ท€ ํ›„ pop()์œผ๋กœ ์ƒํƒœ๋ฅผ ๋ณต๊ตฌํ•˜๋Š” ํ๋ฆ„์ด ์ž˜ ์ฝํ˜”์Šต๋‹ˆ๋‹ค! ํ˜„์žฌ๋„ ์ •๋‹ต์ด์ง€๋งŒ candidates๋ฅผ ๋จผ์ € ์ •๋ ฌํ•œ ๋’ค sum + candidates[i] > target์ผ ๋•Œ breakํ•˜๋ฉด, ๋’ค์˜ ๋” ํฐ ํ›„๋ณด๋ฅผ ๋” ํƒ์ƒ‰ํ•˜์ง€ ์•Š์•„๋„ ๋ผ์„œ ๊ฐ€์ง€์น˜๊ธฐ๋ฅผ ์กฐ๊ธˆ ๋” ์ผ์ฐ ํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”.

Comment thread maximum-subarray/seueooo.js Outdated
dp[i] = Math.max(dp[i - 1] + nums[i], nums[i]);
}

return Math.max(...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.

dp[i]๊ฐ€ ํ˜„์žฌ ์œ„์น˜์—์„œ ๋๋‚˜๋Š” ์ตœ๋Œ€ ์—ฐ์†ํ•ฉ์ด๋ผ๋Š” ํ๋ฆ„์ด ๋ช…ํ™•ํ•ด์„œ ์ฝ๊ธฐ ์ข‹์•˜์Šต๋‹ˆ๋‹ค! ์ด ํ’€์ด์—์„œ๋Š” ์ง์ „ ๊ฐ’๊ณผ ์ „์ฒด ์ตœ๋Œ“๊ฐ’๋งŒ ํ•„์š”ํ•˜๋ฏ€๋กœ, ๋ฐฐ์—ด ๋Œ€์‹  ๋‘ ๋ณ€์ˆ˜๋งŒ ์‚ฌ์šฉํ•˜๋ฉด ๊ณต๊ฐ„์„ O(1)๋กœ ์ค„์ด๊ณ  ๋งˆ์ง€๋ง‰์˜ Math.max(...dp)๋„ ํ”ผํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค.

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.

์˜๊ฒฌ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค:) ๋ฐ˜์˜ํ–ˆ์Šต๋‹ˆ๋‹ค. 7b8764b

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

์ „์ฒด์ ์œผ๋กœ ์ž˜ ๋ดค์Šต๋‹ˆ๋‹ค! ๊ฐ ํ’€์ด์—์„œ ์‚ฌ์šฉํ•œ ํŒจํ„ด์ด ๋ช…ํ™•ํ•˜๊ณ  ์ฝ”๋“œ๋„ ๊ฐ„๊ฒฐํ–ˆ์Šต๋‹ˆ๋‹ค. Combination Sum์˜ ๊ฐ€์ง€์น˜๊ธฐ์™€ Maximum Subarray์˜ ๊ณต๊ฐ„ ์‚ฌ์šฉ ์ชฝ์— ๊ฐœ์„  ์•„์ด๋””์–ด๋งŒ ์งง๊ฒŒ ๋‚จ๊ฒผ์Šต๋‹ˆ๋‹ค. ์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค!

Comment thread 3sum/seueooo.js

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

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

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

ํ”ผ๋“œ๋ฐฑ: ์ •๋ ฌ ์ดํ›„ ์ค‘๋ณต ์ œ๊ฑฐ๋ฅผ ํ†ตํ•ด ํ•„์š” ์—ฐ์‚ฐ์„ ์ค„์ด๊ณ , ๊ฐ i๋งˆ๋‹ค l/h๋ฅผ ์ด๋™์‹œ์ผœ ์ „์ฒด๋ฅผ ๋‘ ํฌ์ธํ„ฐ๋กœ ํƒ์ƒ‰ํ•œ๋‹ค.

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

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

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, DFS
  • ์„ค๋ช…: ์žฌ๊ท€ ํƒ์ƒ‰์œผ๋กœ ๊ฐ€๋Šฅํ•œ ์กฐํ•ฉ์„ ํƒ์ƒ‰ํ•˜๊ณ  ์œ ํšจํ•œ ํ•ด๋ฅผ ๋ฐฑํŠธ๋ž˜ํ‚น์œผ๋กœ ๊ฑธ๋Ÿฌ๋‚ด๋Š” ๊ตฌ์กฐ์ž…๋‹ˆ๋‹ค. ์‹œ์ž‘ ์ง€์ ๋ถ€ํ„ฐ ํ›„๋ณด๋ฅผ ์ฐจ๋ก€๋กœ ์‹œ๋„ํ•˜๊ณ  ํ•ฉ์ด ํƒ€๊นƒ์„ ๋„˜์œผ๋ฉด ์žฌ๊ท€๋ฅผ ์ค‘๋‹จํ•ฉ๋‹ˆ๋‹ค.

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

๋ณต์žก๋„
Time O(N^T/M)
Space O(T/M)

ํ”ผ๋“œ๋ฐฑ: ๊ฐ€๋Šฅํ•œ ๋ชจ๋“  ์กฐํ•ฉ์„ ์ค‘๋ณต ์—†์ด ํƒ์ƒ‰ํ•˜๋Š” DFS ๋ฐฉ์‹์ด๋‹ค. ๊ฐ€์ง€์น˜๊ธฐ ์กฐ๊ฑด(sum > target)์œผ๋กœ ์ผ๋ถ€ ๊ฒฝ์šฐ๋ฅผ ์ ˆ๊ฐํ•œ๋‹ค.

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

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

Comment thread decode-ways/seueooo.js

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 ์ ‘๊ทผ์ด๋‹ค. 1๊ธ€์ž ๋˜๋Š” 2๊ธ€์ž ๋‹จ์œ„๋กœ ๊ฒฝ์šฐ๋ฅผ ๋‚˜๋ˆ„์–ด ๋ˆ„์  ํ•ฉ์„ ๊ตฌํ•˜๋Š” ์ „ํ˜•์ ์ธ DP ๋ฌธ์ œ๋‹ค.

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

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

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

  • ํŒจํ„ด: Dynamic Programming, Greedy
  • ์„ค๋ช…: ๋ฐฐ์—ด์„ ์ˆœํšŒํ•˜๋ฉฐ ํ˜„์žฌ ๊ตฌ๊ฐ„์˜ ์ตœ๋Œ“๊ฐ’์„ ๋ˆ„์ ํ•ด ์ด์ „ ์ƒํƒœ์™€ ๋น„๊ตํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ ๋ถ€๋ถ„๋ฐฐ์—ด์˜ ์ตœ๋Œ€ํ•ฉ์„ ๊ตฌํ•œ๋‹ค. ํ”ผ๋ณด๋‚˜์น˜์ฒ˜๋Ÿผ ์ง์ „ ๊ฒฐ๊ณผ๋ฅผ ์ด์šฉํ•ด ๋‹ค์Œ ๊ฐ’์„ ๊ณ„์‚ฐํ•˜๋Š” DP(๋˜๋Š” ๊ด€์ฐฐ ๊ฐ€๋Šฅํ•œ ๊ทธ๋ฆฌ๋”” ํ˜•ํƒœ) ํŒจํ„ด์— ์†ํ•œ๋‹ค.

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

์œ ์ € ๋ถ„์„ ์‹ค์ œ ๋ถ„์„ ๊ฒฐ๊ณผ
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.

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

  • ํŒจํ„ด: Binary Search, Bit Manipulation, Greedy, Divide and Conquer, Hash Map / Hash Set
  • ์„ค๋ช…: ์ž…๋ ฅ ์ˆซ์ž๋ฅผ ์ด์ง„์ˆ˜๋กœ ๋‹ค๋ฃจ๋ฉฐ, ๊ฐ ๋‹จ๊ณ„์—์„œ n์„ 2๋กœ ๋‚˜๋ˆ  1์˜ ๊ฐœ์ˆ˜๋ฅผ ์„ธ๋Š” ๋ฐฉ์‹์œผ๋กœ ๋น„ํŠธ๋ฅผ ํ™•์ธํ•ฉ๋‹ˆ๋‹ค. ๋น„ํŠธ ๋‹จ์œ„์˜ ์ง์ ‘์  ์กฐ์ž‘๋ณด๋‹จ ๋‚˜๋ˆ—์…ˆ์œผ๋กœ ์ฐจ๋ก€๋กœ ํ™•์ธํ•˜๋Š” ํŒจํ„ด์€ Bit Manipulation ๊ณ„์—ด์— ์†ํ•ฉ๋‹ˆ๋‹ค. ์ถ”๊ฐ€์ ์œผ๋กœ ๊ฐ„๋‹จํ•œ ๋ฐ˜๋ณต์œผ๋กœ ํ•ด๊ฒฐํ•˜๋Š” ๊ตฌ์กฐ๋ผ Divide and Conquer์˜ ์š”์†Œ๊ฐ€ ๋ณด์ผ ์ˆ˜ ์žˆ์Šต๋‹ˆ๋‹ค.

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

์œ ์ € ๋ถ„์„ ์‹ค์ œ ๋ถ„์„ ๊ฒฐ๊ณผ
Time O(log n) O(log 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
  • ์„ค๋ช…: ์ •๊ทœ์‹์œผ๋กœ ๋ฌธ์ž์—ด ์ „์ฒ˜๋ฆฌ ํ›„ ์–‘ ๋์—์„œ ๋™์ผ ์—ฌ๋ถ€๋ฅผ ํ™•์ธํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ๋‘ ํฌ์ธํ„ฐ๋กœ ๋Œ€์นญ ๋น„๊ตํ•˜๋Š” Two Pointers ํŒจํ„ด๊ณผ, ํ•„์š” ์‹œ ํ•œ์ •๋œ ์กฐ๊ฑด์—์„œ ์ตœ์  ๋ถ€๋ถ„์„ ํ™œ์šฉํ•˜๋Š” Greedy ์„ฑ๊ฒฉ์ด ๋ณด์ž…๋‹ˆ๋‹ค. ๋˜ํ•œ ์ž…๋ ฅ ๋ฌธ์ž์—ด์˜ ๋ฌธ์ž ์ œ๊ฑฐ ๋ฐ ๋น„๊ต ๊ณผ์ •์—์„œ ํ•ด์‹œ ๊ฐ™์€ ์ถ”๊ฐ€ ์ž๋ฃŒ๊ตฌ์กฐ๋Š” ์‚ฌ์šฉํ•˜์ง€ ์•Š์•„ ํ•ต์‹ฌ์€ ํˆฌ ํฌ์ธํ„ฐ ๋Œ€์นญ ๋น„๊ต ์ž…๋‹ˆ๋‹ค.

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

์œ ์ € ๋ถ„์„ ์‹ค์ œ ๋ถ„์„ ๊ฒฐ๊ณผ
Time O(n) O(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, Monotonic Stack, DFS, Inorder Traversal
  • ์„ค๋ช…: ์ค‘์œ„ ์ˆœํšŒ(Inorder Traversal)๋กœ ํŠธ๋ฆฌ๋ฅผ ๋ฐฉ๋ฌธํ•˜๋ฉฐ ์ด์ „ ๊ฐ’๊ณผ์˜ ๋Œ€์†Œ๋ฅผ ๋น„๊ตํ•ด BST ์—ฌ๋ถ€๋ฅผ ํ™•์ธ. ์ˆœํšŒ ์ž์ฒด๋Š” DFS์˜ ํ•œ ํ˜•ํƒœ์ด๊ณ , ์ˆœํšŒ ์ค‘ ๊ฐ’์ด ์ฆ๊ฐ€ํ•˜๋Š”์ง€ ๋ชจ๋‹ˆํ„ฐ๋งํ•˜๋Š” Monotonic ํŠน์„ฑ์„ ํ™œ์šฉํ•œ๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ์ „์œ„/์ค‘์œ„ ์ˆœํšŒ์—์„œ์˜ ๋ˆ„์  ๋น„๊ต๋กœ BST ์—ฌ๋ถ€๋ฅผ ํŒ๋ณ„ํ•œ๋‹ค.

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

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

@seueooo seueooo merged commit b12b5df into DaleStudy:main Jul 11, 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