As reported: Adobe Computer Scientist 1 loop (2025), round 1 (DSA, on HackerRank): minimum cost to cut a stick. The candidate recognized it as a standard DP problem, and the interviewer moved on to another question.
This is LeetCode 1547 — Minimum Cost to Cut a Stick.
A wooden stick of length n is marked at positions 0 to n. cuts[i] is a position where you must cut. You may make the cuts in any order. Each cut costs the length of the piece being cut at that moment. Return the minimum total cost.
Example 1
n = 7, cuts = [1,3,4,5]
Output: 16
Cutting at 3, then 5, then 1, then 4 costs 7 + 4 + 3 + 2 = 16.
Example 2
n = 9, cuts = [5,6,1,4,2]
Output: 22
Constraints: 2 ≤ n ≤ 10^6; 1 ≤ cuts.length ≤ min(n - 1, 100); 1 ≤ cuts[i] ≤ n - 1; the cuts are distinct.
Code runner format: one JSON value per line: n, cuts. Implement minCost(n, cuts); the harness prints the cost.