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.
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
[TONY] WEEK 01 solutions #299
[TONY] WEEK 01 solutions #299
Changes from 4 commits
a7576f3
4002eb2
e714695
2a3dfd8
5739f6e
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
nums
리스트에 트리들의 값을 누적하면 최악의 경우에는O(n)
을 차지할 것 같습니다 ㅎㅎ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.
감사합니다! 잘못 생각했네요ㅜ
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.
주석으로 처리하신
while
문으로 입력을 나누어 해결하는 방법의 시간복잡도는O(log n)
이 걸릴 것 같은데,Integer.bitCount
는O(1)
이라고 봐야할까요??단순 연산으로 처리하고 있어서
O(log n)
이라고 보기 힘들지 않을까 싶은데, 토니님은 어떻게 생각하시나요??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.
리뷰 주셔서 감사합니다!
확인해본 결과는 다음과 같습니다.
Integer.bitCount(n) : 시간 복잡도 O(1), 공간 복잡도 O(1)
while 반복문: 시간 복잡도 O(log n), 공간 복잡도 O(1)
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.
오 그렇군요 ㅎㅎ 확인해주셔서 감사합니다.
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.
@TonyKim9401
Integer.bitCount(n)
의 시간 복잡도가O(1)
이라는 것에 대한 레퍼런스 좀 공유해주실 수 있으실까요? 내부적으로 도대체 어떤 알고리즘을 썼길래 입력 값에 무관하게 일정한 시간이 걸리는지 궁금합니다.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.
@DaleSeo 위에 jdalma 님께서 올려주신 코드가 내부적으로 사용하는 코드이네요.
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.
네네, 덕분에 저도 배웠네요! 이런 코드가 실제 코딩 테스트에서 유리할 지 불리할 지에 대해서 모임 때 같이 얘기해보면 좋을 것 같습니다.
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.
이 부분이 얼마나 시간이 걸릴지 분석을 한 번 해보시면 어떨까요? 그 분석을 바탕으로 좀 더 효율적인 알고리즘을 고민해보셔도 좋을 것 같습니다. 이미 문제를 다 푸셔서 시간이 좀 있으실 것 같아서 제안드립니다.
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.
@DaleSeo 이 부분은... GPT에 물어 본 결과였구요 ㅜ 답변 공유해드리는걸로 대체해도 괜찮을까요?
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.
혹시 위 내용은 #299 (comment) 에 대한 답변이 아닐까요? 제가 여쭤본 내용에 대한 답변이 아닌 것 같습니다.