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 acd546c commit ea10dc8Copy full SHA for ea10dc8
4107-find-missing-elements/4107-find-missing-elements.py
@@ -0,0 +1,23 @@
1
+# time complexity: O(n)
2
+# space complexity: O(n)
3
+from typing import List
4
+
5
6
+class Solution:
7
+ def findMissingElements(self, nums: List[int]) -> List[int]:
8
+ minNum = min(nums)
9
+ maxNum = max(nums)
10
+ numSet = set(nums)
11
+ result = []
12
+ for num in range(minNum, maxNum + 1):
13
+ if num not in numSet:
14
+ result.append(num)
15
+ return result
16
17
18
+nums = [1, 4, 2, 5]
19
+print(Solution().findMissingElements(nums))
20
+nums = [7, 8, 6, 9]
21
22
+nums = [5, 1]
23
0 commit comments