Skip to content

[essaysir] WEEK 05 Solutions#2766

Open
essaysir wants to merge 3 commits into
DaleStudy:mainfrom
essaysir:week-05
Open

[essaysir] WEEK 05 Solutions#2766
essaysir wants to merge 3 commits into
DaleStudy:mainfrom
essaysir:week-05

Conversation

@essaysir

@essaysir essaysir commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

โš ๏ธ Week ์„ค์ •์ด ๋ˆ„๋ฝ๋˜์—ˆ์Šต๋‹ˆ๋‹ค

ํ”„๋กœ์ ํŠธ์—์„œ Week๋ฅผ ์„ค์ •ํ•ด์ฃผ์„ธ์š”!

์„ค์ • ๋ฐฉ๋ฒ•

  1. PR ์šฐ์ธก์˜ Projects ์„น์…˜์—์„œ ๋ฆฌํŠธ์ฝ”๋“œ ์Šคํ„ฐ๋”” ์˜† ๋“œ๋กญ๋‹ค์šด(โ–ผ) ํด๋ฆญ
  2. ํ˜„์žฌ ์ฃผ์ฐจ๋ฅผ ์„ ํƒํ•ด์ฃผ์„ธ์š” (์˜ˆ: Week 14(current) ๋˜๋Š” Week 14)

๐Ÿ“š ์ž์„ธํ•œ ๊ฐ€์ด๋“œ ๋ณด๊ธฐ


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

@github-actions github-actions Bot added the java label Jul 22, 2026
@dalestudy

dalestudy Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

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

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

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

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

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

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

์นดํ…Œ๊ณ ๋ฆฌ ์ง„ํ–‰๋„ ์™„๋ฃŒ
Array โ– โ– โ– โ–กโ–กโ–กโ–ก 4 / 10 (Medium 2, Easy 2)
Heap โ– โ– โ–กโ–กโ–กโ–กโ–ก 1 / 3 (Medium 1)
Dynamic Programming โ– โ– โ–กโ–กโ–กโ–กโ–ก 3 / 11 (Easy 1, Medium 2)
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 708 93 801 $0.000073
2 1,188 158 1,346 $0.000123
ํ•ฉ๊ณ„ 1,896 251 2,147 $0.000195

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

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

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

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

  • ํŒจํ„ด: Hash Map / Hash Set, Greedy, Divide and Conquer, Dynamic Programming, Two Pointers, Sliding Window, Fast & Slow Pointers, BFS, DFS, Backtracking, Union Find, Trie, Bit Manipulation, Monotonic Stack, Heap / Priority Queue, Binary Search
  • ์„ค๋ช…: ๋ฌธ์ž์—ด ์ธ์ฝ”๋”ฉ ๊ธธ์ด(prefix length)์™€ ๊ตฌ๋ถ„์ž('#')๋ฅผ ์ด์šฉํ•ด ๋ฌธ์ž์—ด์„ ์ˆœ์ฐจ์ ์œผ๋กœ ํŒŒ์‹ฑํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ๋ฌธ์ž์—ด์˜ ๊ตฌ์„ฑ ์š”์†Œ๋ฅผ ์ˆœํšŒํ•˜๋ฉฐ ๊ตฌ๋ถ„์„ ์ด์šฉํ•ด ๋ถ€๋ถ„ ๋ฌธ์ž์—ด์„ ๋ถ„๋ฆฌํ•œ๋‹ค. ํŠน์ • ๋ฐ์ดํ„ฐ ๋‹จ์œ„๋ฅผ ๋ถ„๋ฆฌํ•˜๊ณ  ์žฌ๊ตฌ์„ฑํ•˜๋Š” ํŒจํ„ด์— ํ•ด๋‹นํ•œ๋‹ค.

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

๋ณต์žก๋„
Time O(sum of lengths)
Space O(sum of lengths)

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

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

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

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

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

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

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

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

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

List<List<String>> answer = new ArrayList<>();
Map<String, List<String>> map = new HashMap<>();

for ( int i = 0; i < strs.length; 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.

๋ฃจํ”„ ์•ˆ์—์„œ i ์ž์ฒด๋ฅผ ์“ฐ์ง€ ์•Š๊ณ  strs[i]๋กœ ๊ฐ’๋งŒ ์ฐธ์กฐํ•  ๋•Œ ๊ฐ€๋…์„ฑ์„ ํ–ฅ์ƒ์‹œํ‚ค๊ธฐ ์œ„ํ•ด์„œ enhanced for-loop์„ ์จ๋ณด๋Š” ๊ฒƒ๋„ ์ข‹์„ ๊ฒƒ ๊ฐ™์Šต๋‹ˆ๋‹ค!

* @param strs: a list of strings
* @return: encodes a list of strings to a single string.
*/
public String encode(List<String> strs) {

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.

'#'์ด encode/decode ์–‘์ชฝ์— ๋งค์ง ๋ฆฌํ„ฐ๋Ÿด๋กœ ์ค‘๋ณต๋˜๊ธฐ ๋•Œ๋ฌธ์—, private static final char DELIMITER = '#';๋กœ ์ถ”์ถœํ•ด์„œ ๋‘ ๋ฉ”์„œ๋“œ์˜ ์ธ์ฝ”๋”ฉ ๊ณ„์•ฝ์ด ํ•œ ๊ณณ์—์„œ ๊ด€๋ฆฌ๋˜๋ฉด ๋‚˜์ค‘์— ๊ตฌ๋ถ„์ž ๋ฐ”๊ฟ€ ๋•Œ ํ•œ์ชฝ๋งŒ ์ˆ˜์ •ํ•˜๋Š” ์‹ค์ˆ˜๋ฅผ ์˜ˆ๋ฐฉํ•  ์ˆ˜ ์žˆ์„ ๊ฒƒ ๊ฐ™์•„์š”!

class Solution {
public int maxProfit(int[] prices) {
int result = 0;
// prices = [7,1,5,3,6,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.

์ตœ์†Œ๊ฐ’ ๋Œ€์‹  ์ตœ์†Œ ์ธ๋ฑ์Šค๋ฅผ ๋“ค๊ณ  ๊ฐ€๋Š” ์ ‘๊ทผ๋„ ๊น”๋”ํ•˜๋„ค์š”.
์ธ๋ฑ์Šค๋กœ ์žก์œผ๋ฉด ๋‚˜์ค‘์— '๋ฉฐ์น ์— ์ƒ€๋Š”์ง€'๊นŒ์ง€ ํ™•์žฅํ•  ๋•Œ ๋ฐ”๋กœ ์“ธ ์ˆ˜ ์žˆ๋Š” ์—ฌ์ง€๊ฐ€ ์žˆ์–ด ์ข‹๋„ค์š”!

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.

์ข‹์€ ์˜๊ฒฌ๋“ค ๋„ˆ๋ฌด ๊ฐ์‚ฌํ•ฉ๋‹ˆ๋‹ค! ์•ž์œผ๋กœ, ์ฝ”๋”ฉ ํ…Œ์ŠคํŠธ ํ•˜๋ฉด์„œ ์ ์šฉํ•ด๋ณผ ์ˆ˜ ์žˆ๋„๋ก ๋…ธ๋ ฅํ•˜๋„๋ก ํ•˜๊ฒ ์Šต๋‹ˆ๋‹ค.

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