41.Cutting a Rod
Input:[1, 5, 8, 9, 10, 17, 17, 20]
8
Output: 22
Explanation:
length | 1 2 3 4 5 6 7 8
--------------------------------------------
price | 1 5 8 9 10 17 17 20
by cutting in two pieces of lengths 2 and 6Input:[3, 5, 8, 9, 10, 17, 17, 20]
8
Output: 24
Explanation:
length | 1 2 3 4 5 6 7 8
--------------------------------------------
price | 3 5 8 9 10 17 17 20
by cutting in eight pieces of length 1.Solution: (Recursion)
Solution: (Recursion + Memo)
Solution: (Dp)
Last updated