Bitonic string | Java program for the above approach ; Function to check if the given String is bitonic ; Check for increasing sequence ; If end of String has been reached ; Check for decreasing sequence ; If the end of String hasn 't  been reached ; Return true if bitonic ; Driver Code ; Given String ; Function Call
import java . util . * ; class GFG { static int checkBitonic ( char [ ] s ) { int 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 ; } public static void main ( String [ ] args ) { String s = " abcdfgcba " ; System . out . print ( ( checkBitonic ( s . toCharArray ( ) ) == 1 ) ? " YES " : " NO " ) ; } }