Showing wrong answer in Biotonic length


here’s my code, its showing wrong answer, though its working for the given test cases as well, help me out here.

Hi Pranshu,
In this problem you have to consider 4 cases i.e
1)array can be increasing then decreasing
2) decreasing then increasing
3) strictly increasing
4) strictly decreasing
hint: 1)construct another array from left to right such that at every ith index of array we have the result which shows the length of non-decreasing subarray ending at the ith index of that array.

2)construct another array from right to left such that at every ith index of array we have the result which shows the length of non-increasing subarray starting at the ith index of that array.
3)
then find the maximum length

Actually in the question there are only three cases given and I also think that there are three cases.
1)array can be increasing then decreasing.
3) strictly increasing
4) strictly decreasing.

Also in this question I have used a completely different approach, like why do we have to increase the space complexity when we can do it without the help of storing the element but rather increasing the value of the counter, But it is giving the same answer.

there was a small error in your code
define max_len=1 not max_len=0.
rest of the code is working perfectly fine.

Thank you, that helped. :slight_smile: