首先练习一下python,使用collection的Counter
查看代码
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
a=Counter(nums)
for i in a:
if a[i] >= 2:
return i
return 1
2024-01-20 11:25:22
首先练习一下python,使用collection的Counter
class Solution:
def findDuplicate(self, nums: List[int]) -> int:
a=Counter(nums)
for i in a:
if a[i] >= 2:
return i
return 1