Maximum Unsorted Subarray
You are given an array (zero indexed) of N non-negative integers, A0, A1 ,…, AN-1. Find the minimum sub array Al, Al+1 ,…, Ar so if we sort(in ascending order) that sub array, then the whole array should get sorted. If A is already sorted, output -1.
Example :
In the above example(Input 1), if we sort the subarray A1, A2, then whole array A should get sorted.
Last updated