
Leetcode Problem 2390: Removing Stars From a String
Given a string s containing letters and '*' characters, repeatedly remove the nearest non-star character to the left of each '*' along with the '*' itself. Return the resulting string after all stars are processed. The input is guaranteed to produce a valid result.
Constraints:
'*'.'*'.function removeStars(s: string): string {
let stack = []
for (let i = 0; i < s.length; i++) {
let currentChar = s.charAt(i)
if (currentChar === "*") {
stack.pop()
} else {
stack.push(currentChar)
}
}
return stack.join("")
};
console.log(removeStars("leet**cod*e"))