I tried it here is my code https://ide.codingblocks.com/s/251352
It is giving 48 instead of 50 would you look into it?
PROBLEM WITH THE CODE OF IT
@sshreya2912
you have to start with y = 1
int Wine(int i, int j, int y, int dp[], int a[]){
if (i > j)
return 0;
return dp[y] = max(y * a[i] + Wine(i + 1, j, y + 1, dp, a), y * a[j] + Wine(i, j - 1, y + 1, dp, a));}
int main(){
int dp[100] = {0};
int n = 5;
int ar[n] = {2, 3, 5, 1, 4};
int i = 0;
int j = n - 1;
cout << Wine(i, j, 1, dp, ar) << endl;
return 0;}
that gives me -12 as the ans I have to make change in function call only right?
When you are calling wine again then you have to do ‘y+1’
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.