for ( int i = 0 ; i < 26 ; i ++ ) append character ( ' a ' + i ) in resultant String ' result ' by min ( count1 [ i ] , count2i ] ) times
{ for ( int j = 1 ; j <= Math . min ( count1 [ i ] , count2 [ i ] ) ; j ++ ) { result += ( char ) ( ' a ' + i ) ; } } System . out . println ( result ) ; }