Is there anything wrong in my code?

For the above question, I have made a logic and it is producing the right output for all the test cases under my thought. Even after submission, one test case is getting passed and other ones are not. So, you should check it once and let me know what is wrong in the logic.
Here is my code: https://ide.codingblocks.com/s/256722

@subham221 it fails on this simple test
1
5
1 3 2 1 1
The approach is incorrect, maintain two arrays inc[ ] and dec[ ] which stores maximum length subarray which is increasing+ending at ith position and decreasing+starting at ith position. So answer is simply max(inc[i]+dec[i]-1) for i : 0 to n-1.

The answer of the input you took must be?. 3 or 4?

@subham221
ans should be 5 for the input mayank provided your code gives 4