Initialize a max heap to keep track of the counts of 'a', 'b', and 'c'.
Add tuples of the form (-count, char) for each character to the heap, with negative counts to simulate a max heap.
Initialize an empty result string.
While the heap is not empty:
a. Pop the character with the highest count from the heap.
b. If the last two characters of the result string are the same as this character:
i. Pop the next character from the heap.
ii. Add this second character to the result string.
iii. Increment its count (since we use negative counts) and push it back into the heap if it's not exhausted.
iv. Push the first character back into the heap.
c. Otherwise, add the first character to the result string and decrement its count.
d. If the count of the first character is not exhausted, push it back into the heap.