Skip to content

[shinsj4653] Week 14 Solutions #1634

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 5, 2025
Merged

[shinsj4653] Week 14 Solutions #1634

merged 2 commits into from
Jul 5, 2025

Conversation

shinsj4653
Copy link
Contributor

@shinsj4653 shinsj4653 commented Jun 30, 2025

답안 제출 문제

작성자 체크 리스트

  • 우측 메뉴에서 PR을 Projects에 추가해주세요.
  • Projects의 오른쪽 버튼(▼)을 눌러 확장한 뒤, Week를 현재 주차로 설정해주세요.
  • 문제를 모두 푸시면 프로젝트에서 StatusIn Review로 설정해주세요.
  • 코드 검토자 1분 이상으로부터 승인을 받으셨다면 PR을 병합해주세요.

검토자 체크 리스트

Important

본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!

  • 바로 이전에 올라온 PR에 본인을 코드 리뷰어로 추가해주세요.
  • 본인이 검토해야하는 PR의 답안 코드에 피드백을 주세요.
  • 토요일 전까지 PR을 병합할 수 있도록 승인해주세요.

@eunhwa99
Copy link
Contributor

eunhwa99 commented Jul 1, 2025

#1608 안녕하세요~ pr승인이 필요해서 부탁드립니다!

Copy link
Contributor

@seungriyou seungriyou left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

리뷰가 늦어져서 죄송합니다 😭 이번 주도 고생 많으셨어요~! 마지막 주까지 화이팅입니다 💪🏻

def countBits(self, n: int) -> List[int]:
dp = [0] * (n + 1)
for num in range(1, n + 1):
dp[num] = dp[num // 2] + (num % 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

가장 오른쪽 비트를 기준으로 하는 DP로 풀이하신 것 같네요!

저의 경우에는 // 2% 2 연산은 비트 연산으로 대체하는 편인데요, 비트 연산이 성능 측면에서 미세하게나마 더 효율적이라고 합니다! 따라서 dp[num] = dp[num >> 1] + (num & 1)로도 작성할 수 있을 것 같아요.

또한, 가장 왼쪽 비트를 기준으로 하는 DP로도 한 번 풀이해보시는 걸 추천드려요~!

@shinsj4653 shinsj4653 merged commit bf1c3a8 into DaleStudy:main Jul 5, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 4기 Jul 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Status: Completed
Development

Successfully merging this pull request may close these issues.

3 participants