Change Minimum Characters to Satisfy One of Three Conditions
Try every boundary letter and count the characters on the wrong side, using letter frequency prefix sums.
Try every boundary letter and count the characters on the wrong side, using letter frequency prefix sums.