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 717ce19 commit da140d7Copy full SHA for da140d7
268.missing-number.py
@@ -0,0 +1,33 @@
1
+# EASY
2
+
3
+# first submission
4
+# runtime: 129 ms O(n)
5
+# memory: 17.4 MB
6
+class Solution:
7
+ def missingNumber(self, nums: list[int]) -> int:
8
+ num = 0
9
+ nums.sort()
10
+ length = len(nums)
11
+ while num < length:
12
+ if nums[num] != num:
13
+ return num
14
15
+ num += 1
16
17
18
19
20
+# second submission
21
22
+# memory: 17.6 MB
23
24
25
+ missing_num = 0
26
27
+ for num in nums:
28
+ if num != missing_num:
29
+ return missing_num
30
31
+ missing_num += 1
32
33
0 commit comments