Greedy Algorithms - Minimum Cost to Connect Sticks
The following Python function attempts to compute the minimum cost to connect sticks:
```python
import heapq
def min_cost_buggy(sticks):
heapq.heapify(sticks)
total = 0
while len(sticks) > 1:
first = heapq.heappop(sticks)
second = heapq.heappop(sticks)
cost = first + second
total += cost
sticks.append(cost) # Bug here
return total
```
What is the subtle bug in this code?
