Skip to content

Instantly share code, notes, and snippets.

@bkb181
Created July 10, 2020 11:19
Show Gist options
  • Save bkb181/5accdda54230ed4a854000fca2762063 to your computer and use it in GitHub Desktop.
Save bkb181/5accdda54230ed4a854000fca2762063 to your computer and use it in GitHub Desktop.
int rod_cut(int price[], int n)
{
if(n== 0)
return 0;
int profit = INT_MIN;
for(int i = 1; i <= n; i++)
{
int cost= price[i-1] + rod_cut(price, n-i);
profit=max(cost, profit);
}
return profit;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment