New answers tagged

1

An easy-to-see algorithm that is potentially much simpler than yours but runs on the same idea is just to simply remove all "AB" pairs first, then remove all "BB" pairs. As you observed, we must have a B in the center of our string in order to keep making it shorter -- and to keep the most B's in the center as opposed to just erasing them ...


Top 50 recent answers are included