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 f886424 commit 34fc9daCopy full SHA for 34fc9da
missing-number/joon.py
@@ -0,0 +1,11 @@
1
+from typing import List
2
+
3
4
+class Solution:
5
+ # Time: O(n)
6
+ # Space: O(1)
7
+ def missingNumber(self, nums: List[int]) -> int:
8
+ n = len(nums)
9
+ # MissingNumber = (Sum of 1, 2, ..., n) - Sum of nums)
10
11
+ return n * (n + 1) // 2 - sum(nums)
0 commit comments