Question
Jump game
Given an array of non- negative integers arr, you are initially positioned at the first index of the array. Each element in the array represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. Print the minimum number of jumps required to reach last index or print -1 if it is not possible.
Input
First line contains a single integer N, size of array.
Second line contains N space separated integers denoting the array.

Constraints:
1 <= N <= 10^3
0 <= arr[i] <= 10^3
Output
A single integer denoting the required answer.
Example
Input:
5
2 3 1 0 4

Output:
2

Explanation:
0 - > 1 - > 4

Online