You are given an integer array nums. You are initially positioned at the array's first index, and each element in the array represents your maximum jump length at that position.
Return true if you can reach the last index, or false otherwise.
Greedy Insight: Track the farthest position you can reach. At each position, update the maximum reachable index. If at any point your current position exceeds the maximum reachable, you're stuck.
Why Greedy Works: We don't need to track all possible paths. We only care about the farthest we can reach from positions we can actually visit. If we can visit position i and nums[i] allows jumping further than our current max, we update our reach.
nums = [2,3,1,1,4]truenums = [3,2,1,0,4]false1 <= nums.length <= 10^40 <= nums[i] <= 10^5Click "Run" to execute your code against test cases
Socratic guidance - I'll ask questions, not give answers