Skip to content

Practice Find Indices With Index and Value Difference I

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2903
LeetCode Problem

Find Indices With Index and Value Difference I

Problem Statement

Find indices i and j satisfying |i-j| >= indexDifference and |nums[i]-nums[j]| >= valueDifference. They may be equal. Return any qualifying [i,j], or [-1,-1] if none exists.

Source: Find Indices With Index and Value Difference I 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 <= 100
0 <= nums[i] <= 50
0 <= indexDifference <= 100
0 <= valueDifference <= 50

Related LeetCode Problems

Practice more problems similar to Find Indices With Index and Value Difference I.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.