You are given a string `s` made of lowercase letters and stars `*`. In one operation you pick a star, then delete it together with the closest non-star character to its left. Return the string after every star has been removed. The input always allows this, and the result is unique.
You are given a string s made of lowercase letters and stars *. In one operation you pick a star, then delete it together with the closest non-star character to its left. Return the string after every star has been removed. The input always allows this, and the result is unique.
Example 1:
Input: {"s":"leet**cod*e"}
Output: lecoe
Constraints:
1≤s.length≤105
s consists of lowercase English letters and stars *.
The operation above can be performed on s.
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"s":"leet**cod*e"}
s; a star and the letter it erased share a colour
l
0
e
1
e
2
t
3
*
4
*
5
c
6
o
7
d
8
*
9
e
10
Scan left to right. Letters go on a stack; the top is always the closest surviving letter to the left of the next character.