You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Given a rod of length n inches and an array of prices that contains prices of all pieces of size smaller than n. Determine the maximum value obtainable by cutting up the rod and selling the pieces.
7
+
8
+
Input Format:
9
+
---------------
10
+
1 5 8 9 10 17 17 20
11
+
12
+
13
+
1 2 3 4 5 6 7 8
14
+
15
+
total no of enteries are the length of the rod
16
+
17
+
Algo strategy:
18
+
-Create the possible permutations in which the rod can be cut up and add up the max vals
19
+
20
+
How:
21
+
val(l) = max{{ val(l-r)+val(r) } for r in range(0, l)}
0 commit comments