Practice Find Indices With Index and Value Difference II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Find indices i and j with abs(i - j) >= indexDifference and abs(nums[i] - nums[j]) >= valueDifference. The indices may be equal. Return any valid [i,j], or [-1,-1] if none exists.
Source: Find Indices With Index and Value Difference II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
nums = [5,1,4,1], indexDifference = 2, valueDifference = 4
Output
[0,3]
# Example 2
Input
nums = [2,1], indexDifference = 0, valueDifference = 0
Output
[0,0]
# Example 3
Input
nums = [1,2,3], indexDifference = 2, valueDifference = 4
Output
[-1,-1]
Constraints
1 <= n == nums.length <= 10^5
0 <= nums[i] <= 10^9
0 <= indexDifference <= 10^5
0 <= valueDifference <= 10^9
Related LeetCode Problems
Practice more problems similar to Find Indices With Index and Value Difference II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.