fork download
  1. # your code goes here
  2. def func(arr, n, K):
  3. hashset = {}
  4.  
  5. for i in range(n):
  6. num = arr[i]
  7.  
  8. if num in hashset and abs(i - hashset[num])<=K:
  9. return True
  10. hashset[num] = i
  11.  
  12. return False
Success #stdin #stdout 0.07s 14068KB
stdin
Standard input is empty
stdout
Standard output is empty