200 – Time
Very Easy
500 – BinaryCode
Easy
1100 – PowerOutage
This problem has an interesting property. It is that if we know the longest weight to a leaf node then we can easily calculate the mininum number of minutes to check all of the transformers.
The property comes from the fact that if the technician want to exit from the ducts then the minimum number of minutes to check all the transformer is twice of the sum of all duct length. So the condition that the techinician doesn`t come out from the last leaf node means that the longgest way to reach for a leaf node lastly is the minimum path to visit all ducts.
So we can get the solution by ”subtract the maximum length to a leaf from the twice of sum of all ducts“.