Maximum length in a Bitonic Subarray

What is wrong with this approach? It is giving me the right output for the sample test cases in the questions, but while submitting no test cases are being passed !
// Bitonic Subarray
#include <bits/stdc++.h>
using namespace std;

int bitonic(int a[], int n){
int c=0;
if(n==0 || n==1 || n==2)
return n;
for(int i=0;i<n-2;i++){
if(a[i]>a[i+1] && a[i+1]<a[i+2]){
c=0;
continue;
}
else
c++;
}
if(n>3)
return c+2;
else
return c;
}
int main() {
int t; cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
for(int i=0;i<n;i++)
cin>>a[i];
int ans = bitonic(a,n);
cout<<ans<<endl;
}
}

hello @daspradhi1812

pls save ur code here->https://ide.codingblocks.com/
and share the link with me

code

image
u need to keep track of maximum value of c .
otherwise u will always print length of last bitonnic subarray

1 Like

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.