62. Contains Nearby Duplicate

Check whether there are two equal numbers at a distance of at most k.
Example 1
Input: nums = [1,2,3,1,2,3], k = 2
Output: False
Explanation: There are duplicates, but the distance between equal elements is greater than 2.
Example 2
Input: nums = [1,2,3,1], k = 3
Output: True
Explanation: The duplicate 1s are at distance 3.
arrayseasyhash table
JavaScript
Loading...
Line 1, Char 1