Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
def containsNearbyDuplicate(nums, k):
index_map = {}
for i in range(len(nums)):
if nums[i] in index_map:
if i - index_map[nums[i]] > k:
index_map[nums[i]] = i
return True
index_map[nums[i]] = i
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.