#3613

Minimize Maximum Component Cost

specialist · 975 · lc medium +32 · 43.4% accepted · 116 likes · top 25%

Description

A connected undirected graph has n nodes and weighted edges [ui, vi, wi]. An integer k is also given.

Remove any number of edges so the resulting graph has at most k connected components. The cost of each component equals its maximum edge weight (0 if it has no edges).

Return the minimum possible value of the maximum component cost.

Code

1
2
3