Question: 
Write a python function to check whether an array can be sorted or not by picking only the corner elements.


Model's Code:
def check(arr, n):
    if n <= 1:
        return True
    
    left, right = 0, n - 1
    sorted_arr = sorted(arr)

    while left < right:
        if arr[left] == sorted_arr[left] and arr[right] == sorted_arr[right]:
            left += 1
            right -= 1
        elif arr[left] == sorted_arr[right] and arr[right] == sorted_arr[left]:
            left += 1
            right -= 1
        else:
            return False

    return True



Sample Correct Code:
def check(arr,n): 
    g = 0 
    for i in range(1,n): 
        if (arr[i] - arr[i - 1] > 0 and g == 1): 
            return False
        if (arr[i] - arr[i] < 0): 
            g = 1
    return True


Asserts:
assert check([3,2,1,2,3,4],6) == True
assert check([2,1,4,5,1],5) == True
assert check([1,2,2,1,2,3],6) == True


Tests:
Test 1 of 3: FAIL: AssertionError()

Test 899 of 974: 692/899 (76.97441601779755%): failed