↵
Find the longest consecutive subarray so that The Last and First member of the sub array is Neither the Smallest or the Biggest member of That subarray (not the entire array)↵
↵
↵
↵
for example↵
↵
1 3 2 4 6 5 7↵
↵
↵
the sub array [3, 2, 4, 6, 5] ↵
↵
in this subarray the smallest member is 2 and the biggest member is 6, the first member is 3 which is not equal to 2 or 6, the last member 5 is not equal to 2 or 6 either so this is a valid subarray, so you cout 2 6 (the l and r of the subarray)↵
↵
↵
↵
The goal is to find a Valid subarray ↵
↵
↵
the second Goal is to find the Biggest valid subarray↵
↵
↵
↵
↵
the numbers are from 0 up to 1e9 ↵
and n is from from 1 up to 2*1e5↵
↵
↵
↵
My strategy is to make a two vector of vectors, saving the numbers sorted from index 0 up to i so you can always know the smallest and biggest member of each subarray and then just do a sliding window algorithm.



