Transform a string such that it has abcd . . z as a subsequence | function to transform string with string passed as reference ; initializing the variable ch to ' a ' ; if the length of string is less than 26 , we can 't obtain the required  subsequence ; if ch has reached ' z ' , it means we have transformed our string such that required subsequence can be obtained ; current character is not greater than ch , then replace it with ch and increment ch ; Driver Code
< ? php function transformString ( & $ s ) { $ ch = " a " ; if ( strlen ( $ s ) < 26 ) return false ; for ( $ i = 0 ; $ i < strlen ( $ s ) ; $ i ++ ) { if ( ord ( $ ch ) > ord ( " z " ) ) break ; if ( $ s [ $ i ] <= $ ch ) { $ s [ $ i ] = $ ch ; $ ch = chr ( ord ( $ ch ) + 1 ) ; } } if ( $ ch <= " z " ) return false ; return true ; } $ str = " aaaaaaaaaaaaaaaaaaaaaaaaaa " ; if ( transformString ( $ str ) ) echo $ str ; else echo " Not ▁ Possible " ; ? >