The editorial of the problem Subway Ride (Problem Code: SUBWAY) of JULY18 has not been made available. When will it uploaded?
I think this problem required HLD.
we need to put the weight of the edges in a set for a particular edge. If any of the two adjacent set is more than 2 then the cost function increases by 1, else if the set sizes are 1 then we need to check the contents of the sets and increase the cost function accordingly
I don’t know when official editorial will be posted. But LCA + DP would give you AC.
Hint :
Even though there are multiple edges of different colors between two nodes you can prove that it is enough to maintain only 3 different color edges.
LCA is Lowest Common ancestor (Video For learning LCA)
Still, If you want to read some nice explanation then read this Comment. It is nicely explained.
1 Like
Thank you!