[WEEK11] 추슬기#50
Merged
Merged
Conversation
LeeBaeJin
approved these changes
Apr 21, 2026
| } | ||
|
|
||
| function countOne(num) { | ||
| return num.toString(2).replace(/0/g, "").length; |
Collaborator
There was a problem hiding this comment.
준호님은 1을 찾으셨고, 슬기님은 0을 지우셨네요!
접근은 비슷하지만 과정에서의 차이를 보는 작은 재미가 있었습니다.
sik9252
approved these changes
Apr 26, 2026
Collaborator
sik9252
left a comment
There was a problem hiding this comment.
ㅠㅠ 일이 많아서 리뷰 까먹고 있었네요 죄송🥹 고생하셨습니다!
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.
이렇게 풀었어요
1. 다음 큰 숫자
1) 복잡도 계산
2) 접근 아이디어
1의 개수를 먼저 구했다.1개수를 가지는지 확인했다.1의 개수가 같아지는 첫 숫자를 답으로 반환했다.3) 회고
이진법 변환이나 이진법 방식을 이해하면 더 쉽게도 풀 수 있을 것 같다.
다른 사람 풀이:
다른 사람 풀이 핵심:
match(/1/g)로 1의 개수를 세고, 재귀로 다음 숫자를 바로 탐색하는 방식이었다.내 생각: match라는 메서드를 활용해서 1과 일치하는 문자열을 배열로 채워서 length로 계산하는 방법도 있었다. 재귀로 푸는 예시도 참고할 만한 듯하다.
2. 숫자의 표현
1) 복잡도 계산
2) 접근 아이디어
n / 2까지 하나씩 올려가며 탐색했다.n이 되면 경우의 수를 하나 늘리고,n을 넘으면 그 시작점 탐색을 중단했다.3) 회고
while문 하나로 푼 방식도 있었는데,
다른 사람 풀이:
다른 사람 풀이 핵심: 연속합을 직접 모두 만들지 않고, while문 하나로
n을 줄여가며 나누어떨어지는 횟수만 세는 방식이었다.내 생각: while문 하나로 푼 방식도 있었는데, 같은 문제를 보는 관점을 수열 합이 아니라 규칙으로 바꿔서 보면 더 간단해질 수 있다는 점이 인상적이었다.