File size: 458 Bytes
bff4ec7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | # Huffman Merge Cost
## Description
Repeatedly merge two available weights, paying their sum each time, until one weight remains. Find the minimum possible total cost.
## Input
The function receives the input weights and a writable work array.
## Output
Return the minimum total merge cost.
## Constraints
- $1 \le n \le 8$.
- $1 \le weight_i \le 1000$.
## Source
Classical Huffman optimal-merge problem reconstructed from the verified C artifact.
|