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.
Challenges 4,5 and 6 where easily accepted (all under 0.5s using python 3) using Prim's algorithm. I don't know why you are trying to minimize lines of code. It's way better to have a lisible and efficient code. Note that you can keep a heap of all potential edges to add to the tree to efficiently retrieve the minimum one.
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #107: Minimal network
You are viewing a single comment's thread. Return to all comments →
Challenges 4,5 and 6 where easily accepted (all under 0.5s using python 3) using Prim's algorithm. I don't know why you are trying to minimize lines of code. It's way better to have a lisible and efficient code. Note that you can keep a heap of all potential edges to add to the tree to efficiently retrieve the minimum one.