There are n houses numbered 1 to n. Every house must get water. You can dig a well in house i for wells[i - 1], or lay a pipe between two houses: pipes[k] = [a, b, cost] connects houses a and b (either direction) for cost.
A house has water if it has its own well or is joined by a chain of pipes to a house that does. Write minCostToSupplyWater(n, wells, pipes) returning the smallest total cost.
- Several pipes may connect the same pair of houses, with different costs
- With no pipes the answer is the sum of all the wells
- Hint for the shape: a well is just a pipe to somewhere