I am facing difficulty understanding this problem

I want more hints. …

Hi @shubhamhalder0

In this question what you can do is make 2 arrays: left and right.
In left array store the length of non-decreasing subarray ending at arr[i]. Create it while traversing on array from left to right.
Similarlry, in right array store the length of non-decreasing subarray ending at arr[i]. This time traverse on array from right to left.
Now find maximum value of (left[i] + right[i] - 1 ). This is your answer.

How do i store the length of the non-decreasing subarray

what happens if the array suddenly becomes decreasing? How will the values change in the aux array?

See i m sharing you the code along with all the comments and explanation. Have a look and try to dry run few cases then you will understand how all works :

1 Like

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.