Code RoomMinimum cost stick cuts
HardPrep Room Coding #1497

Minimum cost stick cuts

CodingAlgorithms & data structuresSenior–Staff~35 min

Given a wooden stick of length L and a list of positions cuts (each strictly between 0 and L) where cuts must be made, you may perform the cuts in any order. The cost of one cut equals the current length of the stick segment being cut. Return the minimum total cost to perform all the cuts. L is at most 1000000 and there are at most 100 cut positions, all distinct.

Implement
min_cost_cut_stick(L: int, cuts: list[int]) → int
Examples
in[7,[1,3,4,5]]out16
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
[7,[1,3,4,5]]16not run yetsample