Sponsored
Sponsored
Solve with full IDE support and test cases
Use these hints if you're stuck. Try solving on your own first.
Use a dynamic programming approach.
Define a dynamic programming array dp of size n, where dp[i] represents the maximum number of jumps from index 0 to index i.
For each j iterate over all i < j. Set dp[j] = max(dp[j], dp[i] + 1) if -target <= nums[j] - nums[i] <= target.