Skip to content

Commit e7a1841

Browse files
committed
Updated jump game
1 parent e7d3edc commit e7a1841

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

Medium/JumpGame.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,15 @@
1616
*/
1717
class JumpGame {
1818
public static void main(String[] args) {
19+
JumpGame j = new JumpGame();
1920
int[] A = {3, 2, 1, 0, 4};
2021
int[] B = {2, 3, 1, 1, 4};
2122
int[] C = {0};
2223
int[] D = {2, 5, 0, 0};
23-
// System.out.println(canJump(A));
24-
// System.out.println(canJump(B));
25-
// System.out.println(canJump(C));
26-
System.out.println(canJump(D));
24+
System.out.println(j.canJump(A));
25+
System.out.println(j.canJump(B));
26+
System.out.println(j.canJump(C));
27+
System.out.println(j.canJump(D));
2728
}
2829

2930
/**
@@ -35,7 +36,7 @@ public static void main(String[] args) {
3536
* maxJump should be max of maxJump - 1 and A[i]
3637
* if maxJump reduces to zero, we are not able to reach anymore
3738
*/
38-
public static boolean canJump(int[] A) {
39+
public boolean canJump(int[] A) {
3940
if (A == null || A.length == 0) return false;
4041
if (A.length == 1) return true; // already reach last index
4142
if (A[0] == 0) return false; // note its important cause we start from 1

0 commit comments

Comments
 (0)