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.
The constraints of the problem say there will always be at least 1 ladder, regardless of how helpful it may be.
If there's no helpful ladder, you'll still get to 100 in 17 rolls. How is 17 not the solution in that case? I could see the need for -1 though, as if six squares in a row have snakes, you can't get past without a ladder.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Snakes and Ladders: The Quickest Way Up
You are viewing a single comment's thread. Return to all comments →
The constraints of the problem say there will always be at least 1 ladder, regardless of how helpful it may be.
If there's no helpful ladder, you'll still get to 100 in 17 rolls. How is 17 not the solution in that case? I could see the need for -1 though, as if six squares in a row have snakes, you can't get past without a ladder.