We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5b77982 commit 4b57613Copy full SHA for 4b57613
โmissing-number/thispath98.py
@@ -0,0 +1,23 @@
1
+class Solution:
2
+ def missingNumber(self, nums: List[int]) -> int:
3
+ """
4
+ Intuition:
5
+ ์ฃผ์ด์ง ๋ฆฌ์คํธ์ ๊ฐ์๋ฅผ ์ป์ด ๋ฒ์๋ฅผ ๊ตฌํ๋ค.
6
+ ์ดํ ์ธํธ๋ฅผ ์ด์ฉํด์ ๋ฒ์ ๋ด์ ์ ์๊ฐ
7
+ ์ธํธ ์์ ์์ผ๋ฉด ๊ทธ ์๋ฅผ ๋ฆฌํดํ๋ค.
8
+
9
+ Time Complexity:
10
+ O(N):
11
+ ์ธํธ(ํด์)๋ ์ ๊ทผํ๋ ๋ฐ์ ์์์ ์๊ฐ์ด ๊ฑธ๋ฆฌ๋ฏ๋ก
12
+ ์ต๋ N + 1๋ฒ์ ์ ๊ทผ์ ํ๋ฏ๋ก
13
+ O(N)์ ์๊ฐ๋ณต์ก๋๊ฐ ์์๋๋ค.
14
15
+ Space Complexity:
16
17
+ ๋ฆฌ์คํธ๋ฅผ ํด์๋ก ๋ณํํ์ฌ ์ ์ฅํ๊ณ ์์ผ๋ฏ๋ก
18
+ O(N)์ ๊ณต๊ฐ๋ณต์ก๋๊ฐ ์์๋๋ค.
19
20
+ num_set = set(nums)
21
+ for i in range(len(nums) + 1):
22
+ if i not in num_set:
23
+ return i
0 commit comments