Getting TLE in max ken biotonic subarray
solution-https://ide.codingblocks.com/s/183511 why tle
please solve this
and
why we are doing -1 in max = inc[0] + dec[0] - 1;
Getting TLE in max ken biotonic subarray
solution-https://ide.codingblocks.com/s/183511 why tle
please solve this
and
why we are doing -1 in max = inc[0] + dec[0] - 1;
You initialised inc[n-1]=1 instead of dec[n-1]=1.
oh i seee thanks ,but one more ques why we are doing -1 in max = inc[0] + dec[0] - 1;
i taken some help from gfg …so i have this daught
For any number at i bitonic length would be the sum of increasing length till i and decreasing length from i. On adding both we will count a[i] twice so we need to subtract one.
you are saying that in inc[ ] & dec[ ]…a no calculated twice or something else
still 1 test case is failing .unable to find
Your code seems to be okay. If you could provide me the question I can have a look at it and see if its asking for strict ordering or not. Also you have raised your doubt in STL section, which is not discussing this problem, it would be better if you raise your doubt in the section in which you face the problem that would helps us in helping you in better way.
You are provided n numbers of array. You need to find the maximum length of bitonic subarray. A subarray A[i … j] is biotonic if there is a k with i <= k <= j such that A[i] <= A[i + 1] … <= A[k] >= A[k + 1] >= … A[j – 1] > = A[j] i.e subarray is first increasing and then decreasing or entirely increasing or decreasing.
First line contains integer t which is number of test case. For each test case, it contains an integer n which is the size of array and next line contains n space separated integers.
Constraints
1<=t<=100 1<=n<=1000000
Output Format
Print the maximum length.
Sample Input
2
6
12 4 78 90 45 23
4
40 30 20 10
Sample Output
5
4
Explanation
ForMaximum length = 4, 78, 90, 45, 23
Please provide me the problem link
Hey I found the question, the issue is with time limit not with the algorithm, use printf and scanf or use
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
and remove endl with “\n” will help you in passing the limit.
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.