update project structure

This commit is contained in:
2024-06-20 06:29:07 +08:00
parent 17b4ef8970
commit fdaa94a0fa
49 changed files with 35 additions and 4 deletions

26
leetcode_py/645.py Normal file
View File

@@ -0,0 +1,26 @@
from typing import List
class Solution:
def findErrorNums(self, nums: List[int]) -> List[int]:
sumSetNums = sum(set(nums))
sumNums = sum(nums)
return [sumNums - sumSetNums, ((len(nums) * (len(nums) + 1)) // 2) - sumSetNums]
def findErrorNums1(self, nums: List[int]) -> List[int]:
n = len(nums)
return_list = [0, 0]
for i in range(1, n + 1):
if i not in nums:
return_list[1] = i
break
for i in range(1, n + 1):
if i in nums:
nums.remove(i)
if i in nums:
return_list[0] = i
break
return return_list