Tap here to switch tabs
Problem
Submissions

Problem: Jump Game VI

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

Statement

You are given an integer array nums and an integer k.

You begin at index 00 of the array. In each move, you can jump from your current index i to any index j such that i <j≤min⁡(< j \leq \min(nums.length −1- 1, i +k)+ k).

Your goal is to reach the final index nums.length −1- 1. The score of your path is the sum of the elements at all visited indices.

Return the maximum possible score you can obtain.

Constraints:

  • 1≤1 \leq nums.length, k ≤105\leq 10^5

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Jump Game VI

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

Statement

You are given an integer array nums and an integer k.

You begin at index 00 of the array. In each move, you can jump from your current index i to any index j such that i <j≤min⁡(< j \leq \min(nums.length −1- 1, i +k)+ k).

Your goal is to reach the final index nums.length −1- 1. The score of your path is the sum of the elements at all visited indices.

Return the maximum possible score you can obtain.

Constraints:

  • 1≤1 \leq nums.length, k ≤105\leq 10^5

  • −104≤-10^4 \leq nums[i] ≤104\leq 10^4