The Question
CodingOptimize Water Distribution Costs
You are tasked with providing water to a neighborhood of n houses. For each house, you can either build a well directly on-site for a specific cost or lay a pipe to connect it to another house that already has access to water, incurring a pipe-laying cost. Given the costs for digging a well at each house and the costs of connecting pairs of houses via pipes, design an algorithm to determine the minimum total expenditure required to ensure every house is supplied with water.
C++
Kruskal's Algorithm
DSU
MST
Greedy
March 1, 2026