Intuition
This is a very classic heap problem. The key idea is to convert the string into a frequency map and then push the frequencies onto the heap as a tuple of (count, char). From there, simply pop off the two most frequent elements until no elements remain.