text: Remove odd frequency characters from the string | C # program to remove the characters having odd frequencies in the string ; Function to remove the characters which have odd frequencies in the string ; Create a map to store the frequency of each character ; To store the new string ; Remove the characters which have odd frequencies ; If the character has odd frequency then skip ; Else concatenate the character to the new string ; Return the modified string ; Driver code ; Remove the characters which have odd frequencies
code: using System ; using System . Collections . Generic ; class GFG { static string removeOddFrequencyCharacters ( string s ) { Dictionary < char , int > m = new Dictionary < char , int > ( ) ; for ( int i = 0 ; i < s . Length ; i ++ ) { char p = s [ i ] ; if ( m . ContainsKey ( p ) ) { m [ p ] ++ ; } else { m [ p ] = 1 ; } } string new_string = " " ; for ( int i = 0 ; i < s . Length ; i ++ ) { if ( ( m [ s [ i ] ] & 1 ) == 1 ) continue ; new_string += s [ i ] ; } return new_string ; } public static void Main ( string [ ] args ) { string str = " geeksforgeeks " ; str = removeOddFrequencyCharacters ( str ) ; Console . Write ( str ) ; } }