Code Room
CodingHardcod-g262
Subject Dp on intervalsLevel Senior–Staff~35 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.