Skip to content

Commit 441e43a

Browse files
author
eunhwa99
committed
jump game
1 parent f8e60a2 commit 441e43a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

jump-game/eunhwa99.java

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

0 commit comments

Comments
 (0)