Skip to content

Commit d004d08

Browse files
committed
Create leetcode645.py
1 parent 2475941 commit d004d08

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

leetcode-645/leetcode645.py

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
from typing import List
2+
3+
class Solution:
4+
def findErrorNums(self, nums: List[int]) -> List[int]:
5+
res = list()
6+
nums.sort()
7+
stdList = range(1, len(nums) + 1) # len(nums) = n
8+
repeatedNum = sum(nums) - sum(set(nums))
9+
res.append(repeatedNum)
10+
missingNum = (set(stdList) - set(nums)).pop()
11+
res.append(missingNum)
12+
return res
13+
14+
# below is testing
15+
sol = Solution()
16+
print(sol.findErrorNums([4,2, 1,2]))

0 commit comments

Comments
 (0)