Search
⌘K

Leetcode 1168. Optimize Water Distribution in a Village

Given per-house well costs and candidate pipe connections with costs, choose wells and pipes to supply water to all houses at minimum total cost. Model this as a minimum spanning tree by adding a virtual source node connected to each house with an edge weight equal to its well cost, then solve with MST/Union-Find or Prim/Kruskal.

Asked at:

Amazon

Amazon


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Late November, 2024

Amazon

Amazon

Mid-level

Optimize warehouse connections to distribution hubs. Given n warehouses with capacities, calculate the minimum total connection cost for all warehouses to the nearest available distribution hub, considering additional hubs placed at specific locations.

Comments

Your account is free and you can post anonymously if you choose.