-
-
Notifications
You must be signed in to change notification settings - Fork 247
[KwonNayeon] Week 11 Solutions #1574
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
이번 주는 한 문제밖에 못 풀었네요... 다음 주는 적어도 세 문제를 푸는 것을 목표로 하겠습니다! |
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.
11주차도 고생많았습니다 :)
nums.sort() | ||
|
||
for i in range(len(nums)): | ||
if nums[i] != i: | ||
for i in range(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)에서 O(1) 로 개선하는 것도 고민해보면 좋을 것 같습니다 :)
class Solution:
def missingNumber(self, nums: List[int]) -> int:
n = len(nums)
expected_sum = n * (n + 1) // 2
actual_sum = sum(nums)
return expected_sum - actual_sum
위 풀이를 참고해보면 좋을 것 같아요!
@shinsj4653 님 리뷰 감사합니다! |
답안 제출 문제
작성자 체크 리스트
In Review
로 설정해주세요.검토자 체크 리스트
Important
본인 답안 제출 뿐만 아니라 다른 분 PR 하나 이상을 반드시 검토를 해주셔야 합니다!