class Solution:
def containsNearbyDuplicate(self, nums: List[int], k: int) -> bool:
seen = set()
for i, num in enumerate(nums):
if num in seen:
return True
seen.add(num)
if len(seen) > k:
seen.remove(nums[i - k])
return False
标签:return,nums,python,II,int,num,seen,leetcode
From: https://blog.csdn.net/Lucy_wzw/article/details/145234369