You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
좋은 시도입니다! 두 가지 방법 모두 비트 연산을 활용하여 문제를 해결하고 있으며, 명확한 구조로 이해하기 쉽습니다. 특히, 두 번째 방법은 효율적이고 직관적입니다.
몇 가지 피드백 드리자면:
시간/공간 복잡도 표기 명확화:
두 번째 방법에 이미 O(N)으로 명시하셨는데, 첫 번째 방법도 비트 연산을 활용했지만, 구체적으로 while 루프를 돌며 각 비트를 검사하므로 시간 복잡도는 O(32)로 간주할 수도 있습니다(정수 크기 제한에 따라). 더 명확하게 O(1) 또는 O(log N)으로 표기하는 것도 고려해보세요. 공간 복잡도는 두 경우 모두 O(1)입니다.
가독성 향상:
첫 번째 방법의 주석이 더 명확하면 좋겠습니다. 예를 들어, "N의 비트 수 만큼 반복하며 각각의 비트를 검사한다" 같은 간단한 설명이 있으면 이해하기 더 쉽습니다.
코드 스타일:
두 번째 방법은 깔끔하고 간결해서 좋습니다. 첫 번째 방법에 불필요한 주석(# idea: -) 대신, 간단한 설명을 달아주시면 더 좋아요.
더 나은 접근법:
이미 두 가지 기본적이고 효율적인 방법을 사용하셨기 때문에 추가 제안은 없습니다. 하지만, 만약 성능 향상이 필요하다면, Brian Kernighan’s Algorithm (n & (n-1)을 반복하는 방법)를 사용할 수도 있는데, 이 방식은 1의 비트 수만큼 반복하므로, 1의 개수가 적은 경우 더 효율적입니다.
전체적으로 잘 작성하셨고, 가독성도 좋아서 리뷰가 긍정적입니다. 앞으로도 다양한 방법을 시도하며 최적의 솔루션을 찾는 연습을 계속하세요!
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
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.
답안 제출 문제
작성자 체크 리스트
In Review로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!