#include
using namespace std;
long long int max_score(long long int a[], int start, int end ,long long int &sum, long long int &maxScore, bool piyush_turn) {
//base case
if(start == end) {
if(maxScore < sum)
maxScore = sum;
sum = 0;
return a[start];
}
if(piyush_turn) {
sum += a[start];
piyush_turn = false;
max_score(a, start + 1, end, sum, maxScore, piyush_turn);
sum += a[end];
piyush_turn = false;
max_score(a, start, end - 1, sum, maxScore, piyush_turn);
}
else {
piyush_turn = true;
max_score(a, start + 1, end, sum, maxScore, piyush_turn);
piyush_turn = true;
max_score(a, start, end - 1, sum, maxScore, piyush_turn);
}
return maxScore;
}
int main() {
int n;
cin >> n;
long long int a[n];
for(int i = 0; i < n; i++) {
cin >> a[i];
}
long long int sum = 0;
long long int maxScore = 0;
long long int score;
score = max_score(a, 0, n - 1, sum, maxScore, true);
cout << score;
return 0;
}
this is my code can you please help me why one test is not passed and other are all passed. I am leaving any corner cases