Code RoomMinimum cost merge stone piles
HardPrep Room Coding #836

Minimum cost merge stone piles

CodingAlgorithms & data structuresSenior–Staff~35 min

There are n piles of stones in a row; stones[i] is the count in pile i. In one move you merge two ADJACENT piles into one, paying a cost equal to the total stones in the two merged piles. Repeat until one pile remains. Return the minimum total cost. 1 <= n <= 200, 1 <= stones[i] <= 100.

Implement
merge_stones_cost(stones: list[int]) → int
Examples
in[[3,4,3]]out17
What 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 35 min
InputExpectedGot
[[3,4,3]]17not run yetsample