Skip to content

Commit

Permalink
Update 0055.跳跃游戏.md
Browse files Browse the repository at this point in the history
  • Loading branch information
nanhuaibeian committed May 12, 2021
1 parent d5c333f commit b09bf15
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion problems/0055.跳跃游戏.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,25 @@ public:
Java:
```Java
class Solution {
public boolean canJump(int[] nums) {
if (nums.length == 1) {
return true;
}
//覆盖范围
int coverRange = nums[0];
//在覆盖范围内更新最大的覆盖范围
for (int i = 0; i <= coverRange; i++) {
coverRange = Math.max(coverRange, i + nums[i]);
if (coverRange >= nums.length - 1) {
return true;
}
}
return false;
}
}
```

Python:

Expand Down

0 comments on commit b09bf15

Please sign in to comment.