Making string T in two halves half1 - first half half2 - second half
StringBuilder half1 = new StringBuilder ( ) , half2 = new StringBuilder ( ) ; for ( char i = ' a ' ; i <= ' z ' ; i ++ ) { for ( int j = 0 ; ( 2 * j ) < mapT . getOrDefault ( i , 0 ) ; j ++ ) { half1 . append ( i ) ; half2 . append ( i ) ; } }