Algorithm · Meta · Medium
Given an unordered integer array A and a window length K, check whether two different positions i and j hold the same value and satisfy i - j <= K. Return true when such a pair exists; otherwise, return false. Example 1: Input: A = [7, 2, 9, 7, 5, 2], K = 5 Output: true Explanation: The value 7 occurs at indices 0 and 3, whose separation is 3, smaller than K=5. Example 2: Input: A = [8, 1, 6, 4, 8], K = 3 Output: false Explanation: The repeated value 8 appears at indices 0…
Checking your access…