| Topic | Difficulty | Companies |
|---|---|---|
| Dynamic Programming | HARD | Amazon Google Ebay |
Given an array of non-negative integers arr[] of length n, where each element represents the max number of steps that can be made forward from that element. You are initially positioned at the first index of the array. Write a program to return the minimum number of jumps to reach the last index of the array.
Problem Note
Example 1
Input: arr[] = [2, 1, 1]
Output: 1
Explanation: The minimum number of jumps to reach the last index is 1. Jump 2 steps from index 0 to 2.
Example 2
Input: arr[] = [2, 3, 2, 4, 4]
Output: 2
Explanation: The minimum number of jumps to reach the last index is 2. Jump 1 step from index 0 to 1, then 3 steps to the last index.