Shortest Un | Bool function for checking an array elements are in increasing ; Bool function for checking an array elements are in decreasing ; increasing and decreasing are two functions . if function return True value then print 0 otherwise 3. ; Driver code
def increasing ( a , n ) : NEW_LINE INDENT for i in range ( 0 , n - 1 ) : NEW_LINE INDENT if ( a [ i ] >= a [ i + 1 ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def decreasing ( a , n ) : NEW_LINE INDENT for i in range ( 0 , n - 1 ) : NEW_LINE INDENT if ( a [ i ] < a [ i + 1 ] ) : NEW_LINE INDENT return False NEW_LINE DEDENT DEDENT return True NEW_LINE DEDENT def shortestUnsorted ( a , n ) : NEW_LINE INDENT if ( increasing ( a , n ) == True or decreasing ( a , n ) == True ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT else : NEW_LINE INDENT return 3 NEW_LINE DEDENT DEDENT ar = [ 7 , 9 , 10 , 8 , 11 ] NEW_LINE n = len ( ar ) NEW_LINE print ( shortestUnsorted ( ar , n ) ) NEW_LINE