Maximum length bitonic subarray


my code is failed the test case, can anyone look up my code?


can anyone look up in this code?

yaaa sorry for the late reply. in your code when the sub array is going from decreasing to increasing use a break statement. i have updated it in your code you can look this (https://ide.codingblocks.com/s/171202).

I didn’t see any break statement or code edited, any where in your link. It looks like same. Can you point it out? And, I’m pretty sure that in my way of code, I didn’t need any break statement for that particular case if I want to. Because my code design in that way.

i think i do not have access to update your code please refer to this (https://ide.codingblocks.com/s/171232)

In my first attempt, I didn’t even take that case which is first decreasing then increasing, and it failed the test case. Then, I included the possibility of this case and by your help, we include else condition with break statement but now it passed the test case. I didn’t understand why? If I’m not taking that else condition with break statement, it’ll fail the test case. Can you give some idea here?

if you just ignore this condition it will continue on checking till ‘k’ reaches ‘j’ and calculates size with only decreasing sequence but that will become subsequence of decreasing elements not subarray

But, i think if you take the subarray (12 4 78 90) from the array(12 4 78 90 35 23) then it’ll give the max length of bitonic subarray=3 in my code because it’ll take the bitonic subarray from 4 to 90 i.e. (4 78 90). Then I think that my whole logic fucked up.

your code will give final answer as 5 because it will consider subarray(4 78 90 35 23) as it is increasing then decreasing. which is correct as per problem statement.

What’s your logic for this problem statement, can you share your code?

first I was thinking about the way we did the problem Rainwater harvesting but it didn’t work out.