#C5948. Minimum Number of Jumps to Reach the End

    ID: 49653 Type: Default 1000ms 256MiB

Minimum Number of Jumps to Reach the End

Minimum Number of Jumps to Reach the End

You are given an array of non-negative integers nums where each element represents your maximum jump length at that position. Your task is to compute the minimum number of jumps required to reach the last index of the array.

Explanation: Starting at the first index, at each step you can jump up to the number specified by the current element. Formally, if you are at index i and the value is nums[i], you can jump to any index in the range \(i+1\) to \(i+nums[i]\). The goal is to determine the smallest number of jumps needed to reach index \(n-1\), where \(n\) is the length of the array.

If the array contains only one element, you are already at the last index and the answer is 0.

inputFormat

The input is given in two lines. The first line contains an integer n representing the number of elements in the array. The second line contains n space-separated integers which represent the array nums.

outputFormat

Output a single integer, the minimum number of jumps required to reach the end of the array.

## sample
5
2 3 1 1 4
2

</p>