You are initially positioned at index 0 of nums. Each element represents your maximum jump length. Return the minimum number of jumps to reach the last index. It is guaranteed you can reach it.
Input: nums = [2,3,1,1,4]
Output: 2
Explanation: Jump to index 1, then jump 3 steps to last index.
Topics: greedy, arrays
Asked by: Amazon, Google, Meta, Microsoft, Apple, Bloomberg
Time complexity: O(n). Space complexity: O(1).