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.
Okay, I had a really hard time trying to understand the sample input, and on reading bretvh's discussion, I have understood it. It seems that people could not understand, and so I will try to explain it to people so they get what you are supposed to do.
The first is pretty clear...He does [1,2] and then does [2,3], which does NOT have any path in common.
Now, for the example [1,2], and [3,4], this is what happens.
He does [1,2].
He then teleports to the city 3.
From city 3, he maintains [3,2] AND [2,4]. These two add up to [3,4].
So, he has done [1,2] and [3,4] without any path being repeated. This is thus counted in the total
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Road Maintenance
You are viewing a single comment's thread. Return to all comments →
Okay, I had a really hard time trying to understand the sample input, and on reading bretvh's discussion, I have understood it. It seems that people could not understand, and so I will try to explain it to people so they get what you are supposed to do.
The first is pretty clear...He does [1,2] and then does [2,3], which does NOT have any path in common.
Now, for the example [1,2], and [3,4], this is what happens.
He does [1,2].
He then teleports to the city 3. From city 3, he maintains [3,2] AND [2,4]. These two add up to [3,4].
So, he has done [1,2] and [3,4] without any path being repeated. This is thus counted in the total