Search
⌘K

Leetcode 2905. Find Indices With Index and Value Difference II

Given an integer array and thresholds k (indexDifference) and t (valueDifference), find any pair of indices i, j with |i−j| ≥ k and |nums[i]−nums[j]| ≥ t, or return [-1,-1] if none exist. The algorithmic challenge is to do this efficiently for n up to 1e5 (e.g., with ordered sets, bucketization, or sorting) rather than brute-force O(n^2).


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.