Water supply network cost
Your task
You must supply water to n cities (1..n). For each city i you can either build a well in it at cost wells[i-1], or lay a bidirectional pipe between two cities given as [a, b, cost] to share water. A city has water if it has its own well or is connected by pipes to a city that has one. Return the minimum total cost to bring water to every city. wells has length n; there can be multiple pipes between the same pair.
Examples
min_water_cost(n: int, wells: list[int], pipes: list[list[int]]) -> intExample 1
Input
min_water_cost(3, [1, 2, 2], [[1, 2, 1], [2, 3, 1]])Output
3