I have used 2 pointer and O(n) approach, still 10 test cases failing

test cases failing :
base-test:- 1,3,7
edge test case:- 1,2,3,4,5,6
perf test:- 2

If your base test is failing, then it has new thing to do with performance. Have you checked out the test case? You can download it and check.

Can you tell me your approach ?

hey, so I initialize 2 pointers Left and Right. Right will iterate from N = len(array) - 1 and left will start from 0. After the iteration Right will have the index where array[right] < array[right -1], and left will have the index where it first encounters the condition array[left] > array[left + 1].

My next step is to find the Min and Max in this subarray from array[left] to array[right]

I then look for a value from i in range(0, left - 1), where array[i] > Min and same with right hand side, i in range(len-1, right + 1) where array[i] < Max

my final answer returns (right - left) + 1

Approach is seems to be correct.

Concept arrays has the old interface. So, Where can I download it from?. Also, it’s not showing any hints also for me

Any edge case that comes to your mind? I’ve handled case where array size is null, and can’t think of any other edge case :sweat_smile:

Hey, the issue is resolved. Please close this thread.

Closing this topic as it has been solved by you yourself. Great job, keep working hard. if its not resolved feel free to un-mark the accepted solution to re-open the topic.