Append the remaining characters to the end of the result
while ( freq [ first ] > 0 ) { answer += String . Join ( " " , ( char ) first ) ; -- freq [ first ] ; } answer += String . Join ( " " , A ) ; for ( int j = ' a ' ; j <= ' z ' ; j ++ )