Back to course home
0% completed
Vote For New Content
Jump Game II (medium)
Problem Statement
You are given an array nums
containing n
integers, where nums[i]
represents the maximum length of a forward jump you can make from index i
. You are initially positioned at nums[0]
.
Return the minimum number of jumps needed to reach from the start
to the end
of the array.
Examples
Example 1:
- Input: nums =
[2, 3, 2, 2, 1]
- Expected Output: 2
- Justification: Start at index 0 and jump to index 1 (jump size 1). Then, jump from index 1 to the end (jump size 3).
Example 2:
- Input: nums =
[1, 2, 3, 4, 5]
.....
.....
.....
Like the course? Get enrolled and start learning!
On this page