Max Length Bitonic Array-Test Cases failing!

I have tried all kind of test-cases, and all are giving the correct answers, however all the test cases are failing when I submit the code. Can someone pls suggest, what’s wrong with my code along with some example test cases?

Here is the link for my code - https://ide.codingblocks.com/s/228002

@dakshguptajune hey you need to use greater than equal to and less than equal to instead of strict comparision.
if this resolves your doubt mark it as resolved.

Thank you for the reply sir.
All the test cases are still showing Wrong Answer.

@dakshguptajune when their is transition from inc to dec or from dec to inc sequence the count is not adjusted properly.
You can follow a simple strategy to have a while loop till the sequence is follows greater than equal to then make another while loop run it till it follows less than equal to. Also keep a variable to record the last position which had strictly smaller then comparision.
After loops update length now start again from the position saved.
Or there is much simpler approach


If this resolves your doubt mark it as resolved.

Sir, the code is showing 3 wrong test cases and 1 correct test case, on submission. Sir I tried it for the case,
1
8
15 17 18 5 4 23 26 30
Answer should be 6, it’s showing 5. The highlighted part being the bitonic sequence.
Thank you for the reply!

@dakshguptajune
hey there was a small mistake in the line.
dec[i]=(arr[i]>arr[i+1])?dec[i+1]+1:1;
it should be
dec[i]=(arr[i]>=arr[i+1])?dec[i+1]+1:1;
if this resolves your doubt mark it as resolved

Thank you sir,it worked!