Trains the technique from
LeetCode 2423Remove Letter To Equalize FrequencyThis is an original problem, written from a brief that listed the technique, the difficulty, the topics, the function shape and the input bounds — none of that problem's wording, examples, hints or editorials. The link is there so you can map your practice onto the standard set.
Same function shape, different story and different numbers.
A florist writes down a bunch of flowers as the string bunch, one lowercase letter per stem, where the letter is the kind of flower.
Before the bunch is wrapped, exactly one stem must be pulled out. Pulling a stem is not optional and no more than one may go. The bunch counts as even when every kind of flower still in it appears the same number of times. A kind whose last stem was the one pulled is no longer in the bunch at all, so it is not compared against anything.
Return true if some single stem can be pulled to leave an even bunch, and false otherwise.
Example 1
Pulling one of the two `f` stems leaves `fgh`, in which each of the three kinds still present appears once.
Example 2
Whichever stem is pulled, one kind is left with two stems and the other with one, so the two kinds present do not appear the same number of times.
Example 3
Pulling the `w` stem leaves `xxx`. The `w` kind is gone from the bunch, so only `x` is compared, and it appears three times.
The editor is preloaded with this. It matches the parent problem's shape, so a solution that works here transfers to a judge unchanged.
def bunch_evens_out(bunch: str) -> bool:public boolean bunchEvensOut(String bunch)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.