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.
It simplifies the path-search code (and only very slightly complicates the input-processing code) if all moves have the same cost. So if there's a ladder from 12 to 98, don't think of it as 12 having a neighbour with no cost. Think of 6, 7, 8, 9, 10 and 11 having 98 as a neighbour (and no longer having 12 for a neighbour at all).
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 →
It simplifies the path-search code (and only very slightly complicates the input-processing code) if all moves have the same cost. So if there's a ladder from 12 to 98, don't think of it as 12 having a neighbour with no cost. Think of 6, 7, 8, 9, 10 and 11 having 98 as a neighbour (and no longer having 12 for a neighbour at all).