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.
Roads and Libraries
Roads and Libraries
Sort by
recency
|
865 Discussions
|
Please Login in order to post a comment
We can use the Disjoint Set Union to solve this question. Hope this helps. Here is the code for same:
My Golang solution:
Does anyone know why the “Sample Test Case #2” came up with a minimum cost of 15? I got a smaller value of 9.
The cities and roads configuration is:
A library for 6 at city #1 and a road, at the cost of 1, to cities #2, #3, and #4; totaling 9.
How did they get 15?