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.
Jumping on the Clouds
Jumping on the Clouds
Sort by
recency
|
3266 Discussions
|
Please Login in order to post a comment
Python 3
def jumpingOnClouds(c):
Here is my c++ solution, you can watch the explanation here : https://youtu.be/GNof9B-9CN0
Python
This solutions separates constants and variables, allowing for faster execution. The max_index and size are constants, allowing us to only measure the length of the array once. For the solution to be optimal, we need to try to jump the furthest we can. Since the question emphasizes that there's always a possible solution, this means that in case there's a dangerous cloud in position + 2 we can always jump to position + 1 and this will be the minimum number of jumps.
Python
RUST: