You are given a 0-indexed integer array nums and two integers, indexDifference and valueDifference.
Your task is to find two indices i and j such that:
abs(i - j) ≥ indexDifference
abs(nums[i] - nums[j]) ≥ valueDifference
Return an integer array answer of length 2, where answer is [i, j] if such indices exist. If no pair of indices satisfies both conditions, return [-1, -1].
If there are multiple valid pairs of indices, return any of them.
Note:
iandjmay be equal.
Constraints:
n nums.length
nums[i]
indexDifference
valueDifference
You are given a 0-indexed integer array nums and two integers, indexDifference and valueDifference.
Your task is to find two indices i and j such that:
abs(i - j) ≥ indexDifference
abs(nums[i] - nums[j]) ≥ valueDifference
Return an integer array answer of length 2, where answer is [i, j] if such indices exist. If no pair of indices satisfies both conditions, return [-1, -1].
If there are multiple valid pairs of indices, return any of them.
Note:
iandjmay be equal.
Constraints:
n nums.length
nums[i]
indexDifference
valueDifference