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 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.
Jumping on the Clouds
You are viewing a single comment's thread. Return to all comments →
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.