Jump Game — JavaScript Coding Problem
Difficulty: medium | Category: greedy
Problem Description
You are given an integer array `nums`. You are initially positioned at the **first index** and each element represents your maximum jump length from that position. Return `true` if you can reach the last index, or `false` otherwise. **Constraints:** - `1 <= nums.length <= 10⁴` - `0 <= nums[i] <= 10⁵` **Hint:** Track the farthest index you can reach at each step.
Examples
Example 1
Input: nums = [2,3,1,1,4]
Output: true
Explanation: Jump 1 to index 1, then 3 to the last.
Example 2
Input: nums = [3,2,1,0,4]
Output: false
Explanation: Always stuck at index 3.