[freemjstudio] WEEK 08 Solutions - #2821
Open
freemjstudio wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
🏷️ 알고리즘 패턴 분석
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) 시간 복잡도를 유지할 수 있다.
💡 풀이에 시간/공간 복잡도를 주석으로 남겨보세요!
Contributor
📊 freemjstudio 님의 학습 현황이번 주 제출 문제
누적 학습 요약
문제 풀이 현황
🤖 이 댓글은 GitHub App을 통해 자동으로 작성되었습니다. 🔢 API 사용량 (gpt-5-nano)
|
parkhojeong
requested changes
Aug 15, 2026
parkhojeong
left a comment
Contributor
There was a problem hiding this comment.
수고하셨습니다.
스터디 규칙을 아직 숙지하지 못하신 것 같은데 해당 문서 확인 부탁드립니다. https://github.com/DaleStudy/leetcode-study/wiki
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!