Problem 1167 · Medium

Minimum Cost to Connect Sticks

Join all sticks into one by repeatedly combining two of them, where each join costs the sum of their lengths, and minimize the total cost. The visual shows a min-heap of stick lengths and each merge it performs.

Open the interactive visualisation