Cant get my mistake
Please share your approach as to what you are trying to do.
I have made the required comments to show my approach . plse check the ide code
Even if you get the mistake, it won’t work because you are finding the increasing and decreasing for every element in O(N) time thus making the complexity go O(N^2). There is a better way of doing this. Look
Please ask if you have any doubts.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.