We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static int jumpingOnClouds(List<Integer> c) {
// Write your code here
int jump=0,temp=0,k=0;
for(int j=k;j<c.size();j++){
if( c.get(j)==0){
temp++;
}
if (c.get(j)==1)
{
k=j;
jump+=temp/2;
temp=0;
jump++;
}
}
if (c.get(c.size()-1)==0 && c.get(c.size()-2)==0) {
jump++;
}
return jump;
}
Cookie support is required to access HackerRank
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 →
Solution i have tried::: Java