1st test case is wrong.
Test case 1(palindrome)
Hello @S19LPN0126,
It is instructed in the question to write a recursive function.
Please, solve these problems as required by the question.
Now, coming back to your doubt:
-
how are you so sure that there would not be more than 20 elements in he array.
Solution:
int n;
cin >> n;
int a[n]; -
Your program is not working if there are even number of elements in the array:
Solution:
2.1. if (b > e){}
because in case of even number, b and e will never be equal
2.1. while( a[b] == a[e] && b<=e){}
As the change in 2.1. will cause problem for odd number, we also modified the condition of while loop.
Hope, this would help.
Give a like, if you are satisfied.
I tried b<=e.
Because of that 1st and 3rd test case are coming out wrong.
And thanks for pointing out recursive function . Forgot that.
You have to implement both the corrections i have specified in point 2.
Here’s your modified code:
Give a like, if you are satisfied.