-
Notifications
You must be signed in to change notification settings - Fork 126
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
[SunaDu] Week 4 #811
[SunaDu] Week 4 #811
Conversation
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.
수고하셨습니다
#### TC is O(n): | ||
- sorting the array. = O(n log n) | ||
- iterating through the array just once to find the missing number. = 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.
선아님 말씀대로라면 시간복잡도는 O(n logn)이어야 하지 않을까요?
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.
아 네 잘못 작성했네요 감사합니다!
missing-number/dusunax.py
Outdated
n = len(nums) | ||
xor_all = 0 | ||
xor_nums = 0 | ||
|
||
for i in range(n + 1): | ||
xor_all ^= i | ||
|
||
for num in nums: | ||
xor_nums ^= num | ||
|
||
return xor_all^xor_nums |
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.
하나로 수정했습니다👍
leetcode-study/missing-number/dusunax.py
Lines 55 to 63 in fe40360
n = len(nums) | |
xor_nums = 0 | |
for i in range(n + 1): | |
if i < n: | |
xor_nums ^= nums[i] | |
xor_nums ^= i | |
return xor_nums |
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.
빠르시네요!! 피드백 반영해주셔서 감사합니다
답안 제출 문제
체크 리스트
In Review
로 설정해주세요.