<s> class Solution : <EOL> def containsNearbyDuplicate ( self , nums , k ) : <EOL> lookup = { } <EOL> for i , num in enumerate ( nums ) : <EOL> if num not in lookup : <EOL> lookup [ num ] = i <EOL> else : <EOL> if i - lookup [ num ] <= k : <EOL> return True <EOL> lookup [ num ] = i <EOL> return False </s>
