Problem Description

Each element tells max jump length. Find minimum jumps needed to reach last index. If not possible, print -1.

Input Format

One line: n then n integers.

Output Format

One integer jumps.

Sample Test Case

Input:
6 2 3 1 1 4 0
Output:
3

Constraints

1

Solutions (0)

No solutions submitted yet. Be the first!

Discussion (0)

No comments yet. Start the discussion!

Prev Next