## 題解 ### 使用 set ```python= class Solution: def findDuplicate(self, nums: List[int]) -> int: # Time complexity: O(n) # Space complexity: O(n) hashSet = set() for num in nums: if num in hashSet: return num else: hashSet.add(num) ```