Creating a HashMap containing char as a key and occurrences as a value
unordered_map < int , int > map ; for ( int i = 0 ; i < n ; i ++ ) { if ( map . count ( arr [ i ] ) ) map . insert ( { arr [ i ] , ( map . count ( arr [ i ] ) + 1 ) } ) ; else map . insert ( { arr [ i ] , 1 } ) ; }