Given
n houses, well costs wells, and pipes pipes (each pipe is [house1, house2, cost]). Minimize the total cost of supplying water to all houses (using wells and/or pipes).Example 1
Input: n = 3, wells = [1,2,2], pipes = [[1,2,1],[2,3,1]]
Output: 3
Explanation: Cheaper to connect houses with pipes.
Output: 3
Explanation: Cheaper to connect houses with pipes.
Example 2
Input: n = 2, wells = [1,1], pipes = [[1,2,1]]
Output: 2
Explanation: Two houses connected by one pipe.
Output: 2
Explanation: Two houses connected by one pipe.