Practice Jump Game V
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
Start at any index of arr. A jump from i to j may move left or right by at most d positions, staying in bounds. It requires arr[j] < arr[i] and every value strictly between i and j to be smaller than arr[i] as well. Return the maximum number of indices that can be visited, including the start.
Source: Jump Game V on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = [6,4,14,6,8,13,9,7,10,6,12], d = 2
Output
4
# Example 2
Input
arr = [3,3,3,3,3], d = 3
Output
1
# Example 3
Input
arr = [7,6,5,4,3,2,1], d = 1
Output
7
Constraints
1 <= arr.length <= 1000
1 <= arr[i] <= 10^5
1 <= d <= arr.length
Related LeetCode Problems
Practice more problems similar to Jump Game V.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.