You are given a nums, an integer indexDifference, and an integer valueDifference.
Your task is to find two indices i and j that satisfy the following conditions:
i j indexDifference
nums[i] nums[j] valueDifference
Return an array [i, j] representing the valid indices. If there are no two indices that satisfy both conditions, return [-1, -1].
Note: The indices
iandjcan be equal. If there are multiple valid solutions, you may return any of them.
Constraints:
n nums.length
nums[i]
indexDifference
valueDifference
You are given a nums, an integer indexDifference, and an integer valueDifference.
Your task is to find two indices i and j that satisfy the following conditions:
i j indexDifference
nums[i] nums[j] valueDifference
Return an array [i, j] representing the valid indices. If there are no two indices that satisfy both conditions, return [-1, -1].
Note: The indices
iandjcan be equal. If there are multiple valid solutions, you may return any of them.
Constraints:
n nums.length
nums[i]
indexDifference
valueDifference