whats wrong in this code?
#include
using namespace std;
int main() {
int test;
cin>>test;
while(test–){
int n;
cin>>n;
int a[n],i,j,inc[n],dec[n];
int len=0,mlen=0;
j=1;
for(i=0;i<n;i++){
cin>>a[i];
if(i==0){
inc[i]=1;
}
else{
if(a[i]>a[i-1])
j++;
else
j=1;
inc[i]=j;
}
}
j=1;
dec[n-1]=1;
for(i=n-2;i>=0;i–){
if(a[i]>a[i+1])
j++;
else
j=1;
dec[i]=j;
}
/for(i=0;i<n;i++){
cout<<inc[i]<<" “;
}
cout<<endl;
for(i=0;i<n;i++){
cout<<dec[i]<<” ";
}
cout<<endl;/
for(i=0;i<n;i++){
len = inc[i]+dec[i]-1;
if(len>mlen)
mlen=len;
}
cout<<mlen<<endl;
}
return 0;
}
Maximum length bitonic subarray
Hey there, you are missing equal to in if(a[i]>a[i+1]),if(a[i]>a[i-1])
check the condition
didnt see the equal conditon, thanks!