I copied the same code but it still doesn’t satisfy all the test cases
Bitonic subarray
#include<bits/stdc++.h> using namespace std; int bitonic(int a[],int n) { int inc[n]; int dec[n]; int i,max; inc[0]=1; dec[n-1]=1; for(i=1;i<n;i++) { inc[i]=(a[i]>a[i-1])?inc[i-1]+1:1; } for(i=n-2;i>=0;i–) { dec[i]=(a[i] > a[i+1])?dec[i+1]+1:1; } max=inc[0]+dec[0]-1; for(int i=1;i<n;i++) { if(inc[i]+dec[i]-1 > max) { max=inc[i]+dec[i]-1; } } return max; } int main() { int test; cin >> test; while(test >0) { int n; cin >> n; int a[n]; for(int i=0;i<n;i++) { cin >> a[i]; } cout << bitonic(a,n) << endl; test–; } }
When are you going to reply??? I sent you my doubt yesterday…
@gaganpreetsachdev1
Check now if it works.If not then please mention if your code is giving Run Error or Wrong Answer on Submission.
Nope it isnt working. On submiting it only satisfies onr test case not others
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.