Given an integer array *nums* and an integer *k*, return `true` if there are two **distinct indices** *i* and *j* such that *nums[i] == nums[j]* and *|i - j| <= k*, and return `false` otherwise.
nums = [array of integers], k = integer
boolean (true/false)
Example 1:
Input:
nums = [1,2,3,1] k = 3
Output:
true
Explanation:
nums[0] == nums[3] = 1 and |0-3|=3 <= k.
Example 2:
Input:
nums = [1,0,1,1] k = 1
Output:
true
Explanation:
nums[2] == nums[3] = 1 and |2-3|=1 <= k.
Example 3:
Input:
nums = [1,2,3,1,2,3] k = 2
Output:
false
Explanation:
No duplicates within distance k=2.