Description
Given a string s containing stars *, remove each star along with its closest non-star character to its left. Return the result.
Examples
Input:
s = "leet**cod*e"Output:
"lecoe"Explanation:
Remove pairs iteratively.
Input:
s = "erase*****"Output:
""Explanation:
Edge case with empty result.
Input:
s = "ab*c*d*"Output:
""Explanation:
Starting with 'ab*c*d*': Remove 'b' and '*' to get 'ac*d*'. Remove 'a' and '*' to get 'cd*'. Remove 'c' and '*' to get 'd*'. Remove 'd' and '*' to get empty string. This shows how consecutive star operations can eliminate the entire string.
Constraints
- •
1 ≤ s.length ≤ 10⁵