2770. Maximum Number of Jumps to Reach the Last Index
You are given a 0-indexed array
nums
ofn
integers and an integertarget
.You are initially positioned at index
0
. In one step, you can jump from indexi
to any indexj
such that:
0 <= i < j < n
-target <= nums[j] - nums[i] <= target
Return the maximum number of jumps you can make to reach index
n - 1
.If there is no way to reach index
n - 1
, return-1
.
1 | class Solution { |