2905. Find Indices With Index and Value Difference II
You are given a 0-indexed integer array
nums
having lengthn
, an integerindexDifference
, and an integervalueDifference
.Your task is to find two indices
i
andj
, both in the range[0, n - 1]
, that satisfy the following conditions:
abs(i - j) >= indexDifference
, andabs(nums[i] - nums[j]) >= valueDifference
Return an integer array
answer
, whereanswer = [i, j]
if there are two such indices, andanswer = [-1, -1]
otherwise. If there are multiple choices for the two indices, return any of them.Note:
i
andj
may be equal.
1 | class Solution { |