Trains the technique from
LeetCode 2390Removing Stars From a StringThis 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 tape tape holds lowercase letters and the character *.
Working from left to right, each * rubs itself out along with the nearest letter still standing to its left.
Return what the tape reads once every * has been dealt with. The tape always leaves a letter for each * to rub out.
Example 1
The first star rubs out the c and the second rubs out the d, leaving the a, the b and the e.
Example 2
Each of the three stars rubs out one of the three letters, so nothing is left.
Example 3
The star rubs out the y, and the x and the z close up together.
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 remove_stars(tape: str) -> str:public String removeStars(String tape)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.