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.
This is my Java 8 solution. Feel free to ask me any questions.
publicstaticintjumpingOnClouds(List<Integer>c){//Start jumping at index 0intposition=0;intjumps=1;intn=c.size();while(position<n-1){//Examine the next two step//Jump out the cloudsif(position+2>=n-1){break;//Move to the next to step if it's good}elseif(c.get(position+2)==0){position=position+2;//Otherwise}elseposition++;//update jumpsjumps++;}returnjumps;}
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 →
This is my Java 8 solution. Feel free to ask me any questions.