Minimum cost to merge reports
Your task
A finance team consolidates expense reports at quarter end. Merging two reports produces one report whose line count is the sum of the two, and the merge costs that many line reviews (every line gets re-checked). Reports can be merged in any order, two at a time, until one remains. Given the line counts of the initial reports, return the minimum total number of line reviews. Zero or one report needs no merging, so the cost is 0. Example: counts = [4, 3, 2, 6] gives 29.
Examples
min_merge_cost(counts: list[int]) -> intExample 1
Input
min_merge_cost([4, 3, 2, 6])Output
29