Trains the technique from
LeetCode 3170Lexicographically Minimum String After Removing StarsThis 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 strip strip holds lowercase letters and the marker character *.
Every marker has to come off the strip, and taking one off also takes off one letter standing to its left. That letter must be one of the smallest letters still standing to the marker's left, and when several of them tie you may take off whichever you please.
Return the smallest word the surviving letters can spell, ordered as a dictionary would. The strip always leaves enough letters for every marker to come off.
Example 1
The smallest letter to the marker's left is a and two of them stand there. Taking off the later one leaves an a nearer the front, which reads smaller.
Example 2
The smallest letter to the marker's left is a, so it goes off along with the marker.
Example 3
The first marker takes off the later a and the second marker takes off the other one, leaving the two b letters.
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 clear_stars(strip: str) -> str:public String clearStars(String strip)See the step-by-step animation, the intuition, and clean code in every language — free, no credit card.