Transform string str1 into str2 by taking characters from string str3 | C # program of the above approach ; Function to check whether str1 can be transformed to str2 ; To store the frequency of characters of String str3 ; Declare two pointers & flag ; Traverse both the String and check whether it can be transformed ; If both pointers point to same characters increment them ; If the letters don 't match check  if we can find it in String C ; If the letter is available in String str3 , decrement it 's  frequency & increment the ptr2 ; If letter isn 't present in str3[]  set the flag to false and break ; If the flag is true and both pointers points to their end of respective Strings then it is possible to transformed str1 into str2 , otherwise not . ; Driver Code ; Function Call
using System ; using System . Collections . Generic ; class GFG { static void convertString ( String str1 , String str2 , String str3 ) { Dictionary < char , int > freq = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < str3 . Length ; i ++ ) { if ( freq . ContainsKey ( str3 [ i ] ) ) freq [ str3 [ i ] ] = freq [ str3 [ i ] ] + 1 ; else freq . Add ( str3 [ i ] , 1 ) ; } int ptr1 = 0 ; int ptr2 = 0 ; bool flag = true ; while ( ptr1 < str1 . Length && ptr2 < str2 . Length ) { if ( str1 [ ptr1 ] == str2 [ ptr2 ] ) { ptr1 ++ ; ptr2 ++ ; } else { if ( freq . ContainsKey ( str3 [ ptr2 ] ) ) if ( freq [ str3 [ ptr2 ] ] > 0 ) { freq [ str3 [ ptr2 ] ] = freq [ str3 [ ptr2 ] ] - 1 ; ptr2 ++ ; } else { flag = false ; break ; } } } if ( flag && ptr1 == str1 . Length && ptr2 == str2 . Length ) { Console . Write ( " YES " + " STRNEWLINE " ) ; } else { Console . Write ( " NO " + " STRNEWLINE " ) ; } } public static void Main ( String [ ] args ) { String str1 = " abyzfe " ; String str2 = " abcdeyzf " ; String str3 = " popode " ; convertString ( str1 , str2 , str3 ) ; } }