Jump Game I
You start at index 0 of a nonempty integer array nums. At index i, you may jump forward by any integer distance from 0 through nums[i], provided you stay…
You start at index `0` of a nonempty integer array `nums`. At index `i`, you may jump forward by any integer distance from `0` through `nums[i]`, provided you stay within the array. Return `true` if you can reach the final index, and `false` otherwise.
- `1 <= nums.length <= 10^4` - `0 <= nums[i] <= 10^5` - The interactive visualizer accepts at most 20 values; longer valid coding inputs are execution-only.
Example 1: input nums = [2, 3, 1, 1, 4]; output true. From index 0 jump to index 1, then jump from index 1 to index 4.
Example 2: input nums = [3, 2, 1, 0, 4]; output false. Index 3 is reachable, but its zero jump leaves index 4 unreachable.
Example 3: input nums = [0]; output true. The starting index is already the final index.
Category: Greedy Algorithms. Topic: greedy. Difficulty: Easy. Patterns: greedy.