More Efficient Code

I wrote a code for this ques and it passed all the cases.
But it’s a bit lengthy code.
I wanted to know if there could be a better and more efficient approach.

refer to this here:


if this solves your doubt ,please mark it as resolved :slight_smile:

But this is giving 2 inputs 1,1 as false which shouldn’t be the case, as it can be broken into two sequences of {1};{1} which is strictly decreasing and strictly increasing.