Skip to content

[std-freejia] week 03 solutions #1805

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 1 commit into from
Aug 9, 2025
Merged

Conversation

std-freejia
Copy link
Contributor

@std-freejia std-freejia commented Aug 9, 2025

답안 제출 문제

작성자 체크 리스트

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

검토자 체크 리스트

Important

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

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

@std-freejia
Copy link
Contributor Author

너무 늦게 올렸네요 늦어도 금요일까지는 in review 로 전환했어야 하는데..

@seungriyou seungriyou self-requested a review August 9, 2025 11:50
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.

이번 한 주도 고생하셨습니다~! 🚀

}
// 2자리 숫자로 해독 가능한 경우
if (num >= 10 && num <= 26) {
dp[i] += dp[i-2];
Copy link
Contributor

Choose a reason for hiding this comment

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

1차원 dp 리스트를 이용한 O(n) space DP로 풀이하셨네요! dp[i]를 계산할 때 매 단계에서 dp[i - 1]과 dp[i - 2]만 확인하기 때문에, 이 값들을 두 개의 변수로 트래킹한다면 O(1) space DP로 최적화를 한 번 더 할 수 있을 것 같습니다~! 😀

Copy link
Contributor Author

Choose a reason for hiding this comment

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

오! 변수로 트래킹 하는 방법도 있네요. 재밌을 것 같아요. 피드백 감사합니다 !!

int count = 0;
while (n > 0) {
if ((n & 1) == 1) count++;
n >>= 1;
Copy link
Contributor

Choose a reason for hiding this comment

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

저도 해당 문제를 풀 때 수학적인 방식과 비트 조작 방식으로 접근했었는데요, 리트코드 솔루션을 보니 Brian Kernighan's Algorithm 이라는 풀이법도 있더라구요! n & (n - 1) 연산을 이용해 오른쪽에서부터 1인 비트를 하나씩 지워가며 개수를 세는 방식으로, n에 포함된 1인 비트 개수만큼만 while 루프를 돌게 된다고 합니다.

참고 자료도 공유드려요~! ➡️ Link

Copy link
Contributor Author

Choose a reason for hiding this comment

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

아. 끝까지 안가도 되는거군요. 링크까지 정말 감사합니다 !! 주말 잘보내세요!💛

Copy link
Contributor

Choose a reason for hiding this comment

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

감사합니다 🙇🏻‍♀️ freejia 님도 좋은 주말 되세요~~!!

@std-freejia std-freejia merged commit 2ca3a2f into DaleStudy:main Aug 9, 2025
3 checks passed
@github-project-automation github-project-automation bot moved this from In Review to Completed in 리트코드 스터디 5기 Aug 9, 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.

2 participants