store the left part of the palindromic String
String left = " " ; for ( int i = 0 ; i < 26 ; i ++ ) { for ( int j = 0 ; j < freq [ i ] ; j ++ ) { left += ( char ) ( i + ' a ' ) ; } } String right = left ;