Minimum cost to merge reports
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.
Implement
min_merge_cost(counts: list[int]) → intExamples
in
[[4,3,2,6]]out29What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 16 min
solution.py
InputExpectedGot
[[4,3,2,6]]29not run yetsample