-
-
Notifications
You must be signed in to change notification settings - Fork 195
[Chaedie] Week 3 #767
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
[Chaedie] Week 3 #767
Conversation
@Chaedie 님 안녕하세요 한 문제를 풀더라도 여러 번 푸시고, 문제 복기도 꼼꼼히 하신 걸 보고 이번주 소홀히 했던 걸 반성했습니다...ㅠㅠ 천천히 리뷰하도록 하겠습니다! |
# 스스로 풀기 | ||
# 한번 더 풀 에정입니다. | ||
def reverseBits(self, n: int) -> int: | ||
result = 0 | ||
for i in range(32): | ||
result = result << 1 | ||
result = result | (n & 1) | ||
n = n >> 1 | ||
return result |
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.
저는 string manipulation을 이용해서 문제를 풀었는데, 비트 연산을 이용한 다양한 풀이방법을 배울 수 있었습니다!
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.
감사합니다..! 문제의 취지가 "비트 연산 사용해보기"인것 같아서 비트 위주로 풀어보았습니다..!
class Solution: | ||
def twoSum(self, nums: List[int], target: int) -> List[int]: | ||
num_map = {} # num : index | ||
|
||
for i, val in enumerate(nums): | ||
diff = target - val | ||
if diff in num_map: | ||
return [num_map[diff], i] | ||
num_map[val] = i |
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.
저는 이중 반복문으로 문제를 풀어서 시간 복잡도가 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.
브루트 포스 -> sort -> hash map 등등 다양한 풀이가 있더라구요. 감사합니다.
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.