45. Jump Game IIMedium
You are given a 0-indexed array of integers
numsof lengthn. You are initially positioned atnums[0].Each element
nums[i]represents the maximum length of a forward jump from indexi. In other words, if you are atnums[i], you can jump to anynums[i + j]where:
0 <= j <= nums[i]andi + j < nReturn the minimum number of jumps to reach
nums[n - 1]. The test cases are generated such that you can reachnums[n - 1].
- Problem
- Solutions