Problem with my code?

#include
#include
using namespace std;
int maximum_value(int input[],int i,int j,int count)
{
if(i==j-1)
return max(input[i],input[j]);
if(input[i]>input[j])
{
if(count%2==0)
return input[i]+maximum_value(input,i+1,j,count+1);
else
return maximum_value(input,i+1,j,count+1);
}
else
{
if(count%2==0)
return input[j]+maximum_value(input,i,j-1,count+1);
else
return maximum_value(input,i,j-1,count+1);
}
}

int main()
{
int n;
cin>>n;
int arr[30];
for(int i=0;i<n;i++)
cin>>arr[i];
cout<<maximum_value(arr,0,n-1,0);
return 0;
}

have u refered to Prateek bhaiaya`s video on optimal game strategy he has nicely explained the concept
once watch that it should be in ur course content
and then attempt the question

please share its link as it is not in my course

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.