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 39f1241 commit cb1b384Copy full SHA for cb1b384
missing-number/samthekorean.py
@@ -0,0 +1,14 @@
1
+# TC : O(n)
2
+# SC : O(n)
3
+class Solution:
4
+ def missingNumber(self, nums: List[int]) -> int:
5
+ n = len(nums)
6
+
7
+ # The sum of the numbers in the range(0,n)
8
+ sumOfNums = (1 + n) * n // 2
9
10
+ # Subtract every element of nums to leave only missing number
11
+ for num in nums:
12
+ sumOfNums -= num
13
14
+ return sumOfNums
0 commit comments