I have been trying to solve following problem from topcoder practice problems:

I have found one of topcoder user’s solution, but I could not understand it. Can somebody please explain me the concept used in code.

```
public class PowerOutage {
public int estmateTimeOut (int[] fromJunction, int[] toJunction, int[] ductLength) {
int result = -maxDuctLength (fromJunction, toJunction, ductLength, 0);
for (int i = 0; i < fromJunction.length; i++) {
result += 2 * ductLength[i];
}
return result;
}
public int maxDuctLength (int[] fromJunction, int[] toJunction, int[] ductLength, int ductNumber) {
int result = 0;
for (int i = 0; i < fromJunction.length; i++) {
if (ductNumber == fromJunction[i]) {
result = Math.max(result, ductLength[i] + maxDuctLength(fromJunction,toJunction,ductLength,toJunction[i]));
}
}
return result;
}
```

}