Custom TestCase passed but testcase 1 not passing .
code :
TestCase 1 not passed
logic:
-
Construct an auxiliary array inc[] from left to right such that inc[i] contains length of the nondecreaing subarray ending at arr[i].
For A[] = {12, 4, 78, 90, 45, 23}, inc[] is {1, 1, 2, 3, 1, 1} -
Construct another array dec[] from right to left such that dec[i] contains length of nonincreasing subarray starting at arr[i].
For A[] = {12, 4, 78, 90, 45, 23}, dec[] is {2, 1, 1, 3, 2, 1}. -
Once we have the inc[] and dec[] arrays, all we need to do is find the maximum value of (inc[i] + dec[i] β 1).
For {12, 4, 78, 90, 45, 23}, the max value of (inc[i] + dec[i] β 1) is 5 for i = 3.
i have modified your code see in comments
NOTE: please donβt use unusal whitespaces and new line it create problem for us first we have to remove all unnecessary blank line and then think to debug