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.
Guys, this is a math problem. The solution lies in understanding that it's just walks and jumps. The solution can be defined as:
floor((n+walks)/2), where n is the total number of clouds. A walk in this case represents a forced walk (when there is an even number of clouds between two consecutive thunderclouds)
My solution in python:
defjumpingOnClouds(c):# Write your code heren=len(c)walks=0last_thunderhead=-1foriinrange(n):ifc[i]:if(i-last_thunderhead)%2:walks+=1last_thunderhead=ireturnmath.floor((n+walks)/2)
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 →
Guys, this is a math problem. The solution lies in understanding that it's just walks and jumps. The solution can be defined as: floor((n+walks)/2), where n is the total number of clouds. A walk in this case represents a forced walk (when there is an even number of clouds between two consecutive thunderclouds)
My solution in python: