Transform a string such that it has abcd . . z as a subsequence | C # Program to transform the given string to contain the required 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
using System ; using System . Text ; using System . Collections . Generic ; class GFG { static bool transformString ( ref StringBuilder s ) { char ch = ' a ' ; if ( s . Length < 26 ) return false ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ( int ) ch > 122 ) break ; if ( s [ i ] <= ch ) { s [ i ] = ch ; ch = ( char ) ( ( int ) ch + 1 ) ; } } if ( ch <= ' z ' ) return false ; return true ; } public static void Main ( ) { StringBuilder str = new StringBuilder ( " aaaaaaaaaaaaaaaaaaaaaaaaaa " ) ; if ( transformString ( ref str ) ) Console . WriteLine ( str + " STRNEWLINE " ) ; else Console . WriteLine ( " Not ▁ Possible " + " STRNEWLINE " ) ; } }