242. Jump Game
MediumGreedy
From index i you may jump up to a[i] steps forward. Starting at index 0, print YES if you can reach the last index, else NO.
Input format
Line 1: n Line 2: n non-negative integers
Output format
YES or NO
Example 1
Input
5 2 3 1 1 4
Output
YES
Example 2
Input
5 3 2 1 0 4
Output
NO
Constraints
1 ≤ n ≤ 10⁵
Read input from standard input and print the answer to standard output. Your code is judged against 6 test cases, most of them hidden.
Loading the MyLoginn IDE…