Shortest Un | boolean function to check array elements are in increasing order or not ; boolean function to check array elements are in decreasing order or not ; increasing and decreasing are two functions . if function return true value then prlet 0 otherwise 3. ; Driver Code
function increasing ( a , n ) { for ( let i = 0 ; i < n - 1 ; i ++ ) if ( a [ i ] >= a [ i + 1 ] ) return false ; return true ; } function decreasing ( arr , n ) { for ( let i = 0 ; i < n - 1 ; i ++ ) if ( arr [ i ] < arr [ i + 1 ] ) return false ; return true ; } function shortestUnsorted ( a , n ) { if ( increasing ( a , n ) == true || decreasing ( a , n ) == true ) return 0 ; else return 3 ; } let ar = [ 7 , 9 , 10 , 8 , 11 ] ; let n = ar . length ; document . write ( shortestUnsorted ( ar , n ) ) ;