Given an integer list nums along with an integer k, determine whether two different positions i and j exist for which nums[i] equals nums[j] and the distance between their indices satisfies abs(i - j) <= k.
Example 1:
Input: nums = [4,7,9,4], k = 3
Output: true
Explanation: The value 4 occurs at indices 0 and 3, whose index gap is 3.
Example 2:
Input: nums = [8,5,8,2], k = 2
Output: true
Explanation: The matching 8 values are located at indices 0 and 2, and their distance is 2.
Example 3:
Input: nums = [6,1,4,6,1,4], k = 2
Output: false
Explanation: Each repeated number appears more than two indices away from its other occurrence.
nums is between 1 and 10^5, inclusive.nums[i] lies in the range -10^9 through 10^9.k is in the inclusive range 0 to 10^5.