GreedyArrayDynamic Programming
You start at the first index of an array. Each value is the maximum number of steps you can jump forward from that index. Decide whether you can reach the last index.
Input
Line 1: n. Line 2: n non-negative integers.
Output
Print true if the last index is reachable, otherwise false.
Constraints
1 <= n <= 10^5 0 <= each value <= 10^5
Example 1
Input
5 2 3 1 1 4
Output
true
Jump 1 step to index 1, then 3 steps to the end.
Example 2
Input
5 3 2 1 0 4
Output
false
Every path ends on the 0 at index 3.