Jump game minimum jumps

Write codeMedium25 min

Your task

You are given an array where nums[i] is the maximum forward jump length from index i. Starting at index 0, return the minimum number of jumps needed to reach the last index. It is guaranteed the last index is reachable. Constraints: 1 <= n <= 10^4, 0 <= nums[i] <= 1000.

Examples

min_jumps(nums: list[int]) -> int
Example 1
Inputmin_jumps([2, 3, 1, 1, 4])
Output2