text: Convert given Strings into T by replacing characters in between strings any number of times | c # program for the above approach ; Function to check if it possible to make all the strings equal to the string T ; Stores the frequency of all the strings in the array arr [ ] ; Stores the frequency of the string T ; Iterate over the characters of the string T ; Iterate in the range [ 0 , N - 1 ] ; Iterate over the characters of the string arr [ i ] ; If freqT [ i ] is 0 and freqS [ i ] is not 0 ; If freqS [ i ] is 0 and freqT [ i ] is not 0 ; If freqS [ i ] is not freqT [ i ] * N ; Otherwise , return " Yes " ; Driver Code
code: using System ; public class GFG { static string checkIfPossible ( int N , string [ ] arr , string T ) { int [ ] freqS = new int [ 256 ] ; int [ ] freqT = new int [ 256 ] ; foreach ( char ch in T . ToCharArray ( ) ) { freqT [ ch - ' a ' ] ++ ; } for ( int i = 0 ; i < N ; i ++ ) { foreach ( char ch in arr [ i ] . ToCharArray ( ) ) { freqS [ ch - ' a ' ] ++ ; } } for ( int i = 0 ; i < 256 ; i ++ ) { if ( freqT [ i ] == 0 && freqS [ i ] != 0 ) { return " No " ; } else if ( freqS [ i ] == 0 && freqT [ i ] != 0 ) { return " No " ; } else if ( freqT [ i ] != 0 && freqS [ i ] != ( freqT [ i ] * N ) ) { return " No " ; } } return " Yes " ; } public static void Main ( string [ ] args ) { string [ ] arr = { " abc " , " abb " , " acc " } ; string T = " abc " ; int N = arr . Length ; Console . WriteLine ( checkIfPossible ( N , arr , T ) ) ; } }