Rod cutting for maximum revenue
Asked at Jane Street
You have a rod of integer length n and a price list where price[k] is what a piece of length k sells for. You may cut the rod into any number of integer-length pieces (or leave it whole). Return the maximum total revenue.
price = [0, 1, 5, 8, 9], n = 4 -> 10 # two pieces of length 2: 5 + 5
# price[0] is unused; price[1..4] = 1, 5, 8, 9
Return the best revenue. Target .
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.