-
-
Notifications
You must be signed in to change notification settings - Fork 245
[HerrineKim] Week 4 #826
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
[HerrineKim] Week 4 #826
Changes from 4 commits
6c8cc95
e6cab98
021d8fe
3ce1527
6ccf94c
0716dae
a7eff01
e051a94
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// 시간 복잡도: O(n) | ||
// 공간 복잡도: O(n) | ||
|
||
/** | ||
* @param {number[]} nums | ||
* @return {number} | ||
*/ | ||
var missingNumber = function(nums) { | ||
const numSet = new Set(nums); | ||
|
||
for (let i = 0; i <= nums.length; i++) { | ||
if (!numSet.has(i)) { | ||
|
||
return 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.
Set 자료구조로 데이터 조회 시간복잡도를 O(1)로 처리하신 부분이 좋아보여요 👍
메모리를 좀 더 활용하게 되어서 공간복잡도가 O(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.
@GangBean 가우스 덧셈 공식을 사용해 최적화해봤습니다! 🙇