Company: Harness On campus Sdet_19march
Difficulty: medium
In Harness CI/CD, a deployment pipeline consists of a sequence of stages arranged in order. To optimize execution time, an engineer can merge adjacent stages into a single combined stage. When two adjacent stages are merged, the combined stage has a workload equal to the sum of the two original workloads, and the merge itself incurs a cost equal to that combined workload. The engineer repeats this process until all stages are merged into one. Given a sequence of stage workloads, find the minimum total cost to merge all stages into a single stage by repeatedly combining adjacent stages. Example workloads = [7, 6, 8, 6, 1, 1] One optimal sequence of merges: (7, 6, 8, 6, 1, 1) merge 1+1=2, cost=2 -> (7, 6, 8, 6, 2) (7, 6, 8, 6, 2) merge 6+2=8, cost=8 -> (7, 6, 8, 8) (7, 6, 8, 8) merge 7+6=13, cost=13 -> (13, 8, 8) (13, 8, 8) merge 8+8=16, cost=16 -> (13, 16) (13, 16) merge 13+16=29, cost=29 -> (29) Total cost = 2 + 8 + 13 + 16 + 29 = 68 Return 68 Function Description Comple