1168. Optimize Water Distribution in a Village
Last updated
Last updated
**Input:** n = 3, wells = [1,2,2], pipes = [[1,2,1],[2,3,1]]
**Output:** 3
**Explanation:**
The image shows the costs of connecting houses using pipes.
The best strategy is to build a well in the first house with cost 1 and connect the other houses to it with cost 2 so the total cost is 3.**Input:** n = 2, wells = [1,1], pipes = [[1,2,1]]
**Output:** 2