char arr[] = {'a', 'b', 'e', 'f', 'd', 'g', 'h', 'i'}; calculate the point where array is not sorted , in this case arr[4] = 'd' calulate k in array[5..n] such that k > 4 arr[k] < d , take the min = min{ arr[k] } same thing for max from reverse use quick /selection sort to identify the correct insertion indices of min/max, that will be answer. complexity O(n)
On Nov 24, 2:06 pm, Ankuj Gupta <ankuj2...@gmail.com> wrote: > Given an unsorted array arr[0..n-1] of size n, find the minimum length > subarray arr[s..e] such that sorting this subarray makes the whole > array sorted. -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.