Skip to content

Practice Removing Stars From a String

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2390
LeetCode Problem

Removing Stars From a String

Problem Statement

Repeatedly select a star in s and remove both that star and the closest remaining non-star character to its left. The input guarantees every required removal is possible, and the final result is independent of removal order. Return the string after all stars are removed.

Source: Removing Stars From a String on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "leet**cod*e"
Output
"lecoe"

# Example 2

Input
s = "erase*****"
Output
""

Constraints

1 <= s.length <= 10^5
s consists of lowercase English letters and stars *.
The operation above can be performed on s.

Related LeetCode Problems

Practice more problems similar to Removing Stars From a String.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.