-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
35 lines (24 loc) · 742 Bytes
/
Solution.java
File metadata and controls
35 lines (24 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
package leetcode.jumpGame;
class Solution {
public boolean canJump(int[] nums) {
int finalJump = nums.length-1;
for(int i = nums.length-1; i > 0; i--){
int capacityJump = nums[i-1];
if(capacityJump + i-1 >= finalJump){
finalJump = i-1;
}
}
if(finalJump>0){
return false;
}
return true;
}
public static void main(String[] args) {
Solution s = new Solution();
int[] prices = {3,2,1,0,4};
boolean resultExpected = false;
boolean result = s.canJump(prices);
System.out.println("Result: " + result);
System.out.println("Result Expected: "+ resultExpected);
}
}