Exemple #1
0
        private static int MaximumRevenue(int length, int[] prices)
        {
            int revenue = prices[length];

            for (int i = 1; i < length; i++)
            {
                revenue = Math.Max(revenue, prices[i] + RodCuttingTests.MaximumRevenue(length - i, prices));
            }

            return(revenue);
        }
Exemple #2
0
        private static int[] MaximumRevenues(int[] prices)
        {
            int[] revenues = new int[prices.Length];

            for (int i = 1; i < prices.Length; i++)
            {
                revenues[i] = RodCuttingTests.MaximumRevenue(i, prices);
            }

            return(revenues);
        }