text: Print characters having odd frequencies in order of occurrence | C ++ implementation of the approach ; Function to print the odd frequency characters in the order of their occurrence ; To store the frequency of each of the character of the string ; Initialize all elements of freq [ ] to 0 ; Update the frequency of each character ; Traverse str character by character ; If frequency of current character is odd ; Driver code
code: #include <bits/stdc++.h> NEW_LINE using namespace std ; #define SIZE  26 NEW_LINE void printChar ( string str , int n ) { int freq [ SIZE ] ; memset ( freq , 0 , sizeof ( freq ) ) ; for ( int i = 0 ; i < n ; i ++ ) freq [ str [ i ] - ' a ' ] ++ ; for ( int i = 0 ; i < n ; i ++ ) { if ( freq [ str [ i ] - ' a ' ] % 2 == 1 ) { cout << str [ i ] ; } } } int main ( ) { string str = " geeksforgeeks " ; int n = str . length ( ) ; printChar ( str , n ) ; return 0 ; }