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.
defjumpingOnClouds(c):jumps=0zeros_count=0fori,cloudinenumerate(c):ifcloud==0andi==0:#Do not count the first 0 as a jumpzeros_count+=1elifcloud==0:# each next 0 is considered 1 jumpjumps+=1zeros_count+=1else:zeros_count=0ifzeros_count==3:# each 3 zeros in a row I remove 1 jump and set zero count as 1jumps-=1zeros_count=1returnjumps
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 →