text: Print characters and their frequencies in order of occurrence | C # implementation to print the characters and frequencies in order of its occurrence ; Store all characters and their frequencies in dictionary ; Print characters and their frequencies in same order of their appearance ; Print only if this character is not printed before ; Driver Code
code: using System ; using System . Collections ; using System . Collections . Generic ; class GFG { public static void prCharWithFreq ( string s ) { Dictionary < char , int > d = new Dictionary < char , int > ( ) ; foreach ( char i in s ) { if ( d . ContainsKey ( i ) ) { d [ i ] ++ ; } else { d [ i ] = 1 ; } } foreach ( char i in s ) { if ( d [ i ] != 0 ) { Console . Write ( i + d [ i ] . ToString ( ) + " ▁ " ) ; d [ i ] = 0 ; } } } public static void Main ( string [ ] args ) { string s = " geeksforgeeks " ; prCharWithFreq ( s ) ; } }