Given test cases are passing but getting wrong answer on submitting
#include
#include
#define ll long long
using namespace std;
int main() {
ll t,n;
cin>>t;
while(t–)
{
cin>>n;
vector arr(n);
for(ll i=0;i<n;i++)cin>>arr[i];
vector left(n,1),right(n,1);
for(ll i=1;i<n;i++)
{
if(arr[i]>=arr[i-1])
{
left[i]=left[i-1]+1;
}
else
left[i]=left[i-1];
}
for(ll i=n-2;i>=0;i–)
{
if(arr[i]>=arr[i+1])
{
right[i]=right[i+1]+1;
}
else
right[i]=right[i+1];
}
ll ans=left[0]+right[0]-1;
for(ll i=1;i<n;i++)
ans=max(ans,left[i]+right[i]-1);
cout<<ans<<"\n";
}
return 0;
}
Maximum length Biotonic Not Working!
save your code on the online ide
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.