Approach to the problem

how to approach to this problem?

@tusharbhardwaj127

Initialize I[0] to 1 and D[n-1] to 1

Creating I[] array
a. Till end of the array ie, i=1 to n, if arr[i] > arr[i-1] then I[i] = I[i-1] + 1. else, I[i] = 1

Creating D[] array
a. From the end of the array ie, i = n-2 till i =0, if arr[i] > arr[i+1] then D[i] = D[i +1] +1 else, D[i] = 1

Now the answer would be
max of ( l[i] + D[i] - 1) for all i
one array is increasing subarray, other one is decreasing subarray.

i tried implementing it,but it fails 3 test-cases…is there any problem in the code?

@tusharbhardwaj127
The question ans for >= and <= . You missed the ‘=’ rest of the code was fine.