← 返回 stripe 的题目列表Bitfront
类型:online_judge
Given an array of non-negative integers where each element represents your maximum jump length at that position. Your goal is to reach the last index in the minimum number of jumps. Return the minimum number of jumps needed.
Example:
Input: [2,3,1,1,4]
Output: 2
Explanation: Jump from index 0 to index 2, then jump from index 2 to the last index.
Input: [2,3,0,1,4]
Output: 2
Note that you can always reach the last index.
Example
Input
[2,3,1,1,4]
Output
2