You are viewing a single comment's thread. Return to all comments →
Simple solution in java Hope you like it : )
public static int jumpingOnClouds(List<Integer> c) { int jumps = 0; int n =c.size()-1; int lastPos=0; for(int i = 2;i<=n;i+=2){ if(c.get(i)==1){ i--; jumps++; } else{ jumps++; } lastPos = i; } if(lastPos==n-1){ jumps++; } return jumps; }
Seems like cookies are disabled on this browser, please enable them to open this website
Jumping on the Clouds
You are viewing a single comment's thread. Return to all comments →
Simple solution in java Hope you like it : )