Check if a given string is a Reverse Bitonic String or not | Function to check if the given string is reverse bitonic ; Check for decreasing sequence ; If end of string has been reached ; Check for increasing sequence ; If the end of string hasn 't been reached ; If the string is reverse bitonic ; Driver Code
function checkReverseBitonic ( s ) { var i , j ; for ( i = 1 ; i < s . length ; i ++ ) { if ( s [ i ] < s [ i - 1 ] ) continue ; if ( s [ i ] >= s [ i - 1 ] ) break ; } if ( i == s . length - 1 ) return 1 ; for ( j = i + 1 ; j < s . length ; j ++ ) { if ( s [ j ] > s [ j - 1 ] ) continue ; if ( s [ j ] <= s [ j - 1 ] ) break ; } i = j ; if ( i != s . length ) return 0 ; return 1 ; } var s = " " ; ( checkReverseBitonic ( s ) == 1 ) ? document . write ( " " ) : document . write ( " " ) ;