-
-
Notifications
You must be signed in to change notification settings - Fork 304
[Donghae0230] WEEK 03 solutions #2118
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
Conversation
seungriyou
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
이번 한 주도 고생 많으셨습니다!
| def devide_by_2 (self, n, temp): | ||
| if n > 1 : | ||
| temp.append(n % 2) | ||
| return self.devide_by_2(n // 2, temp) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
n & n-1로 오른쪽에서부터 1인 비트를 하나씩 지워가며 개수를 세는 방식인 Brian Kernighan's 알고리즘이라는 방법도 있어 공유드립니다~!
| return | ||
| for i in range(start, len(candidates)): | ||
| combination.append(candidates[i]) | ||
| backtrack(i, combination) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
가독성 좋은 백트래킹 풀이인 것 같습니다!
여기에 추가로 candidates를 정렬한다면 pruning을 적용할 수 있어 더 최적화 된 풀이가 가능할 것 같아요~!
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!