← 返回 waymo 的题目列表Reachability / Jump Game Variant (Backtracking)
类型:online_judge
Problem: Jump Game Variant (Reachability / Backtracking)
Given an integer array nums of length n, you start at index 0.
nums[i] is the maximum jump length from index i to the right.
From i, you may jump any distance in 1..nums[i].
Task
Determine whether you can reach the last index n-1.
I/O
Input: one line integer array nums
Output: true or false
Constraints
1 <= n <= 2 * 10^5
0 <= nums[i] <= 10^9
Examples / Tests
[2,3,1,1,4] -> true
[3,2,1,0,4] -> false
[0] -> true
[1,0,1,0] -> false
[2,0,0] -> true
Example
Input
[2,3,1,1,4]
Output
true