![]() |
VOOZH | about |
Given a rod of length n and an array price[]. price[i] denotes the price of a piece of length i. Determine the maximum amount obtained by cutting the rod into pieces and selling the pieces.
Note: price[0] is always 0.
Input: price[] = [0, 1, 5, 8, 9, 10, 17, 17, 20]
Output: 22
Explanation: The maximum obtainable value is 22 by cutting in two pieces of lengths 2 and 6, i.e., 5 + 17 = 22.Input : price[] = [0, 3, 5, 8, 9, 10, 17, 17, 20]
Output : 24
Explanation : The maximum obtainable value is 24 by cutting the rod into 8 pieces of length 1, i.e, 8*price[1]= 8*3 = 24.Input : price[] = [0, 3]
Output : 3
Explanation: There is only 1 way to pick a piece of length 1.
Table of Content
22
22
22
22