-
Notifications
You must be signed in to change notification settings - Fork 0
LC 0219 [E] Contains Duplicate II
Code with Senpai edited this page Apr 1, 2022
·
1 revision
class Solution:
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
d = {}
for i, x in enumerate(nums):
if x in d and abs(i - d[x]) <= k:
return True
d[x] = i
return False
footer