Skip to content

Commit 6b9bb1e

Browse files
committed
solve jump game
1 parent 340e1d1 commit 6b9bb1e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

jump-game/sora0319.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
public class Solution {
2+
public boolean canJump(int[] nums) {
3+
int longLength = 0;
4+
for (int i = 0; i < nums.length; i++) {
5+
if (i > longLength) return false;
6+
longLength = Math.max(longLength, i + nums[i]);
7+
}
8+
return true;
9+
}
10+
}

0 commit comments

Comments
 (0)