## 題解 ### 使用 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) ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up