class Solution { // similar to knapsack problem : consider length of rod array as weight array /** Recursion */ public int cutRod(int[] price) { int n = price.length; // create a length array similar to weight array // Lengths of corresponding rod pieces. int[] length = new int[n]; for(int i=0; i