Google | Onsite | Almost Sorted Array
Anonymous User
10889

Given an array arr. Return True if it is an almost sorted array, and False if it's not.
arr is almost sorted if there is an element arr[i] such that the rest of the array are sorted.
i.e. arr[0] <= arr[1] <= ... <= arr[i-2] <= arr[i-1] <= arr[i+1] <= arr[i+2] <= ... <= arr[n-2] <= arr[n-1]

Comments (20)