class Solution:
def jump(self, nums: List[int]) -> int:
"""
Function to find the minimum number of jumps to reach the last index.
The function uses a greedy algorithm approach where it iteratively identifies the farthest it
can reach from the current position and makes a jump to the position that gives the maximum
reach.
Args:
nums (List[int]): List of non-negative integers representing the maximum jump length at each position.
Returns:
int: The minimum number of jumps needed to reach the last index.
"""
jumps = 0
current_jump_end = 0
farthest = 0
for i in range(len(nums) - 1):
farthest = max(farthest, i + nums[i])
if i == current_jump_end:
jumps += 1
current_jump_end = farthest
return jumps