Problem
You get a string s with lowercase letters and star characters (*). In one operation, you pick a star in s. Then you remove the star and the closest letter on its left.
Do this operation until s has no stars, and return the result. Each star always has a letter on its left to remove. The result does not depend on the order of the operations.
Example 1
- Input:
- s = "ab*cde**f"
- Output:
- "acf"
- Explanation:
- The first star removes
b. The next two stars removeeand thend.
Example 2
- Input:
- s = "xy**"
- Output:
- ""
- Explanation:
- Each star removes one letter, so the result is an empty string.
Example 3
- Input:
- s = "a*b*c"
- Output:
- "c"
Constraints
- 1 <= s.length <= 10^5
- s has only lowercase English letters and the character *.
- You can always do the operation on s.
SysRound wrote this statement. A reference solution checks every example.
Related questions
Continue with questions that share topics or the same question type.
Sources · 1 reference
These records explain where the question appears. A company tag or candidate report does not guarantee a future interview question.
Hello Interview · 1 record
No company association
Leetcode 2390. Removing Stars From a String
Reported date not specified · 0 source reports
Source snapshot: Nov 12, 2026
View source