Tap here to switch tabs
Problem
Submissions

Problem: Jump Game V

med
30 min
Try to solve the Jump Game V problem.

Statement

You are given an integer array arr and an integer d. In a single move, you can jump from your current index i to another index j if all of the following conditions hold:

  • 0≤j<0 \leq j < arr.length

  • 1≤∣i−j∣≤1 \leq |i - j| \leq d

  • arr[i] > arr[j]

  • arr[i] > arr[k] for every index k strictly between i and j (that is, min⁡(i,j)<k<max⁡(i,j)\min(i, j) < k < \max(i, j))

You may choose any valid index as your initial starting position.

Return the maximum number of indices you can visit.

Constraints:

  • 1≤1 \leq arr.length ≤1000\leq 1000

  • 1≤1 \leq arr[i] ≤105\leq 10^5

  • 1≤1 \leq d ≤\leq arr.length

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Jump Game V

med
30 min
Try to solve the Jump Game V problem.

Statement

You are given an integer array arr and an integer d. In a single move, you can jump from your current index i to another index j if all of the following conditions hold:

  • 0≤j<0 \leq j < arr.length

  • 1≤∣i−j∣≤1 \leq |i - j| \leq d

  • arr[i] > arr[j]

  • arr[i] > arr[k] for every index k strictly between i and j (that is, min⁡(i,j)<k<max⁡(i,j)\min(i, j) < k < \max(i, j))

You may choose any valid index as your initial starting position.

Return the maximum number of indices you can visit.

Constraints:

  • 1≤1 \leq arr.length ≤1000\leq 1000

  • 1≤1 \leq arr[i] ≤105\leq 10^5

  • 1≤1 \leq d ≤\leq arr.length