Grokking 75: Top Coding Interview Questions
Vote
0% completed
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!
V F
· 2 years ago
The output for [2, 3, 1, 1, 4] should be 3 while the submission expects 2. Is there a justification to expecting 2?