kindly check my code and rectify it
Maximum length bitonic subarray
@Legendankit
you are trying to make all the subarray and then identify for them, but here n is large so O(N^2) will not work. Try to optimize it.
@Legendankit
what you can do to optimize it is, at every index i we want to know the maximum forward and backward distance we can move by taking care of given conditions for bitonic subarrray.
So just make two array inc[] and dec[] where inc[i] will tell you the maximum length of increasing sub array ending at i and for dec[i] maximum len of decreasing subarray starting at j.
then just take max(inc[i] + dec[i] - 1)
1 Like