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.
Edit - after discussing with @petrovovitch, I see that the shortcut I "discovered" is Kruskal's Minimum Spanning Tree algorithm, and has nothing to do with the edge weights being distinct or being powers of 2 - but either way, it does work. Subsequently counting edge use, as he suggests, is how I solved it as well.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Roads in HackerLand
You are viewing a single comment's thread. Return to all comments →
Edit - after discussing with @petrovovitch, I see that the shortcut I "discovered" is Kruskal's Minimum Spanning Tree algorithm, and has nothing to do with the edge weights being distinct or being powers of 2 - but either way, it does work. Subsequently counting edge use, as he suggests, is how I solved it as well.