You are viewing a single comment's thread. Return to all comments →
That doesn't work because of something like "aabb". Both characters need to change, but your solution would find that there are an even number of each, so nothing needs to change. If you increment the character counts for the first half of the string and decrement for the second half, then discard the negatives and sum the positives, I think that would work.