feat: 2025-10-28打卡
This commit is contained in:
23
55.jump-game.java
Normal file
23
55.jump-game.java
Normal file
@@ -0,0 +1,23 @@
|
||||
/*
|
||||
* @lc app=leetcode id=55 lang=java
|
||||
*
|
||||
* [55] Jump Game
|
||||
*/
|
||||
|
||||
// @lc code=start
|
||||
class Solution {
|
||||
public boolean canJump(int[] nums) {
|
||||
int cur = 0;
|
||||
for(int i=0;i<nums.length;i++) {
|
||||
if(i > cur) {
|
||||
return false;
|
||||
}
|
||||
if(nums[i]>0) {
|
||||
cur = Math.max(cur, i+nums[i]);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// @lc code=end
|
||||
|
||||
Reference in New Issue
Block a user