What is problem in my code?

#include
using namespace std;

void enter_element(int a[],int n)
{
for(int i=0;i<n;i++)
cin>>a[i];
}

int biotonic (int a[],int n)
{
int inc[n],dec[n];
inc[0]=1;
dec[n-1]=1;

for(int i=1;i<n;i++)
	inc[i]=(a[i]>a[i-1])?inc[i-1]+1:1;
	

for(int i=n-2;i>=0;i--)
dec[i]=(a[i]>a[i+1])?dec[i+1]+1:1;

int max=inc[0]+dec[0]-1;
for(int i=1;i<n;i++)
{//-1 is done to remove the element which counted double in both the array 
	int t=inc[i]+dec[i]-1;
	if(t>max)
	max=t;
}

return max;
}

int main()
{
int test;
cin>>test;
while(test–)
{
int n;
cin>>n;
int a[n];
enter_element(a,n);
cout<<biotonic(a,n)<<endl;
}
}

Hi, inside of for loop instead of inc[i]=(a[i]>a[i-1])?inc[i-1]+1:1; it should be inc[i]=(a[i]>=a[i-1])?inc[i-1]+1:1; you missed = sign and same for dec array it should be dec[i]=(a[i]>=a[i+1])?dec[i+1]+1:1;

Now , if you will submit your solution then 4 out of 5 test cases would pass and u will get TLE for 1 test case and that will be becausr the input data is very large so you have to use scanf for reading input insead of cin as scanf is faster than cin

I have updated your code:

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.