-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathJump_Game.java
More file actions
36 lines (28 loc) · 727 Bytes
/
Jump_Game.java
File metadata and controls
36 lines (28 loc) · 727 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
36
/*
Leetcode Problem: 55.Jump Game
*/
class Solution {
public boolean canJump(int[] nums) {
if(nums[0]==0){
if(nums.length == 1)
return true;
else
return false;
}
for(int i=0; i< nums.length-1; i++){
if(nums[i] == 0){
int x= 2;boolean flag=true;
for(int j=i-1; j>=0; j--){
if(nums[j] < x)
{ flag=false;}
else
{ flag=true;break;}
x+=1;
}
if(flag == false)
return false;
}
}
return true;
}
}