Skip to content

[freemjstudio] WEEK 09 Solutions - #2821

Open
freemjstudio wants to merge 1 commit into
DaleStudy:mainfrom
freemjstudio:freemjstudio-week09
Open

[freemjstudio] WEEK 09 Solutions#2821
freemjstudio wants to merge 1 commit into
DaleStudy:mainfrom
freemjstudio:freemjstudio-week09

Conversation

@freemjstudio

Copy link
Copy Markdown
Contributor

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

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

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

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

Important

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

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

@dalestudy

dalestudy Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

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

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

์„ค์ • ๋ฐฉ๋ฒ•

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

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


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

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.

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

reverse-bits/freemjstudio.py
class Solution:
    def reverseBits(self, n: int) -> int:
        # 1. convert integer into binary
        binary = bin(n)[2:]

        # 2. convert into 32bits
        fill_zero = 32 - len(binary)
        binary = "0" * fill_zero + binary

        # 3. reverse the binary
        reversed_binary = binary[::-1]

        # 4. convert binary into integer
        return int(reversed_binary,2)
  • ํŒจํ„ด: Bit Manipulation, Divide and Conquer
  • ์„ค๋ช…: ์ฃผ์–ด์ง„ ์ฝ”๋“œ๋Š” ์ด์ง„์ˆ˜ ํ‘œํ˜„์„ ๋‹ค๋ฃจ๋ฉฐ ๋น„ํŠธ ๋ฐ˜์ „์„ ์ˆ˜ํ–‰ํ•˜๋Š” ๋ฐฉ์‹์œผ๋กœ, ๋น„ํŠธ ์กฐ์ž‘์˜ ์•„์ด๋””์–ด๋ฅผ ์ง์ ‘์ ์œผ๋กœ ์‚ฌ์šฉํ•œ๋‹ค. ๋˜ํ•œ ์ž…๋ ฅ์„ 32๋น„ํŠธ๋กœ ๊ณ ์ •์‹œํ‚ค๊ณ  ์—ญ์ˆœ์œผ๋กœ ์žฌ๋ฐฐ์น˜ํ•˜๋Š” ๊ณผ์ •์—์„œ ๋ถ„ํ•  ์—†์ด ๋ฌธ์ž์—ด ์กฐ์ž‘์œผ๋กœ ๋ฐ˜์ „ํ•˜๋Š” ๋ฐฉ์‹์„ ๋ณด์—ฌ์ค€๋‹ค.

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

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

ํ”ผ๋“œ๋ฐฑ: ์ •์ˆ˜์˜ ์ด์ง„ ํ‘œํ˜„์„ ๋ฌธ์ž์—ด๋กœ ๋‹ค๋ฃจ๊ณ  ์™ผ์ชฝ ํŒจ๋”ฉ๊ณผ ๋ฐ˜์ „์„ ํ†ตํ•ด ์—ญ์ˆœ ์ด์ง„์ˆ˜๋ฅผ ์–ป๋Š”๋‹ค.

๊ฐœ์„  ์ œ์•ˆ: ํ˜„์žฌ ๊ตฌํ˜„์€ ์ง๊ด€์ ์ด์ง€๋งŒ, ๋น„ํŠธ ์—ฐ์‚ฐ๋งŒ์œผ๋กœ 32๋น„ํŠธ ๋ฐ˜์ „์„ ์ˆ˜ํ–‰ํ•˜๋ฉด ๋” ๋น ๋ฅด๊ณ  ๋ฉ”๋ชจ๋ฆฌ ํšจ์œจ์ ์ด๋‹ค. ์˜ˆ: ๋น„ํŠธ ๋งˆ์Šคํฌ์™€ ์‰ฌํ”„ํŠธ๋ฅผ ์ด์šฉํ•œ ์—ญ์ˆœ ์—ฐ์‚ฐ์œผ๋กœ O(1) ์‹œ๊ฐ„ ๋ณต์žก๋„๋ฅผ ์œ ์ง€ํ•  ์ˆ˜ ์žˆ๋‹ค.

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

@dalestudy

dalestudy Bot commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

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

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

๋ฌธ์ œ ๋‚œ์ด๋„ ์œ ํ˜• ๋ถ„์„
reverse-bits Easy โš ๏ธ ์œ ํ˜• ๋ถˆ์ผ์น˜

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

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

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

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

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

๐Ÿ”ข API ์‚ฌ์šฉ๋Ÿ‰ (gpt-5-nano)
์š”์ฒญ ์ž…๋ ฅ ํ† ํฐ ์ถœ๋ ฅ ํ† ํฐ ํ•ฉ๊ณ„ ๋น„์šฉ
1 315 52 367 $0.000037

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

์ˆ˜๊ณ ํ•˜์…จ์Šต๋‹ˆ๋‹ค.

์Šคํ„ฐ๋”” ๊ทœ์น™์„ ์•„์ง ์ˆ™์ง€ํ•˜์ง€ ๋ชปํ•˜์‹  ๊ฒƒ ๊ฐ™์€๋ฐ ํ•ด๋‹น ๋ฌธ์„œ ํ™•์ธ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค. https://github.com/DaleStudy/leetcode-study/wiki

Comment on lines +3 to +14
# 1. convert integer into binary
binary = bin(n)[2:]

# 2. convert into 32bits
fill_zero = 32 - len(binary)
binary = "0" * fill_zero + binary

# 3. reverse the binary
reversed_binary = binary[::-1]

# 4. convert binary into integer
return int(reversed_binary,2)

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.

๋ฌธ์ž์—ด ์กฐ์ž‘ ์—†์ด ๋น„ํŠธ ์—ฐ์‚ฐ๊ณผ ๊ฐ™์€ ๋ฐฉ์‹ ๋“ฑ์œผ๋กœ ํ’€์–ด๋ณด์…”๋„ ์ข‹์„ ๊ฑฐ ๊ฐ™์Šต๋‹ˆ๋‹ค.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants