The Question
Coding
Optimize Water Distribution Costs
Given a set of $n$ locations, you need to provide water to every location at the minimum possible cost. You have two options for each location: either build an onsite water source at a specific local cost or lay a pipeline to connect it to another location that already has access to water, where each pipe has an associated construction cost. Multiple pipes can exist between the same two locations. Design an algorithm to determine the minimum total expenditure required to ensure every location is supplied.
Java
Kruskal's
DSU
MST
March 1, 2026