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 a304ffa commit 64f05e3Copy full SHA for 64f05e3
0645-set-mismatch/0645-set-mismatch.py
@@ -0,0 +1,24 @@
1
+# time complexity: O(n)
2
+# space complexity: O(n)
3
+from typing import List
4
+
5
6
+class Solution:
7
+ def findErrorNums(self, nums: List[int]) -> List[int]:
8
+ length = len(nums)
9
+ countArray = [0] * (length + 1)
10
+ same, miss = 0, 0
11
+ for num in nums:
12
+ countArray[num] += 1
13
14
+ for i in range(1, len(countArray)):
15
+ if countArray[i] == 2:
16
+ same = i
17
+ if countArray[i] == 0:
18
+ miss = i
19
20
+ return [same, miss]
21
22
23
+nums = [1, 1]
24
+print(Solution().findErrorNums(nums))
0 commit comments