173. Contains Duplicate II
EasyHash Table
Given an integer array nums and an integer k, return true if there are two distinct indices i and j in the array such that nums[i] == nums[j] and abs(i - j) <= k.
Examples
Input: [1,2,3,1] 3
Output: true
Explanation: The two 1s are at indices 0 and 3, gap 3 <= k.
Constraints
- 1 <= nums.length <= 10^5
- -10^9 <= nums[i] <= 10^9
- 0 <= k <= 10^5
Loading...
Run checks all cases above. Submit evaluates all test cases.