Tap here to switch tabs
Problem
Submissions

Problem: Find Indices With Index and Value Difference I

med
30 min
Try to solve the Find Indices With Index and Value Difference I problem.

Statement

You are given a 00 indexed integer array nums, an integer indexDifference, and an integer valueDifference.

Your task is to find two indices i and j that satisfy the following conditions:

  • ∣\lvert i −- j ∣≥\rvert \geq indexDifference

  • ∣\lvert nums[i] −- nums[j] ∣≥\rvert \geq 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 i and j can be equal. If there are multiple valid solutions, you may return any of them.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤50\leq 50

  • 0≤0 \leq indexDifference ≤100\leq 100

  • 0≤0 \leq valueDifference ≤50\leq 50

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Find Indices With Index and Value Difference I

med
30 min
Try to solve the Find Indices With Index and Value Difference I problem.

Statement

You are given a 00 indexed integer array nums, an integer indexDifference, and an integer valueDifference.

Your task is to find two indices i and j that satisfy the following conditions:

  • ∣\lvert i −- j ∣≥\rvert \geq indexDifference

  • ∣\lvert nums[i] −- nums[j] ∣≥\rvert \geq 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 i and j can be equal. If there are multiple valid solutions, you may return any of them.

Constraints:

  • 1≤1 \leq n ==== nums.length ≤100\leq 100

  • 0≤0 \leq nums[i] ≤50\leq 50

  • 0≤0 \leq indexDifference ≤100\leq 100

  • 0≤0 \leq valueDifference ≤50\leq 50