Check if string can be made lexicographically smaller by reversing any substring | Function that returns true if s can be made lexicographically smaller by reversing a sub - string in s ; Traverse in the string ; Check if $s [ $i + 1 ] < $s [ $i ] ; Not possible ; Driver code
< ? php function check ( $ s ) { $ n = strlen ( $ s ) ; for ( $ i = 0 ; $ i < $ n - 1 ; $ i ++ ) { if ( $ s [ $ i ] > $ s [ $ i + 1 ] ) return true ; } return false ; } $ s = " geeksforgeeks " ; if ( check ( $ s ) ) echo " Yes " ; else echo " No " ; ? >