Suppose I have a string of A's and B's. I can either remove a character from either end of the string for a cost of 1, or I can remove any character from the middle for a cost of 2. What's the minimum cost to create a string of only A's?
For example, if I have the string "BBABAA", then the minimum cost to remove is 4, since I would remove the B's from the left for a cost of 2, then remove the singular B from the right for a cost of 2 (or remove a A then a B which cost of 2), resulting in a combined cost of 4.
I didn't solve it then and still can't solve it now, any one can come up with this one?