Description
Given an array of non-negative integers, you are initially positioned at the first index of the array.
Each element in the array represents your maximum jump length at that position.
Determine if you are able to reach the last index.
Example 1:
1 | Input: [2,3,1,1,4] |
Example 2:
1 | Input: [3,2,1,0,4] |
Difficulty: Medium
Code:
1 | class Solution { |
题意
有一个非负数组,每个数字表示在当前位置最大能跳跃的跨度,初始位置在第一个位置,求是否能达到最后一个位置。