class Solution:
def canJump(self, nums: List[int]) -> bool:
"""
Function to determine if it's possible to reach the last index of the array.
The function implements a greedy algorithm approach. The key idea is to iterate through the array
and keep track of the farthest reachable index. If at any point, the farthest reachable index
is less than the current index, it means we cannot proceed further, and hence we cannot reach
the end of the array.
Args:
nums (List[int]): List of non-negative integers representing the maximum jump length at each position.
Returns:
bool: True if the last index can be reached, False otherwise.
"""
max_reachable = 0
for i, jump_length in enumerate(nums):
if i > max_reachable:
return False
max_reachable = max(max_reachable, i + jump_length)
if max_reachable >= len(nums) - 1:
return True
return False