Remove every digit and the nearest non-digit character to its left, then return the remaining string.
You are given a string containing lowercase letters and digits. Process the string from left to right, and whenever you encounter a digit, remove that digit and also remove the closest character to its left that has not already been removed.
After all digits have been processed, return the remaining string.
The relative order of the characters that remain should stay the same as in the original string.
s consisting of lowercase English letters and digits.1 <= s.length <= $10^{5}$s contains only lowercase English letters and digits.Example 1
Input
s = "cb34"
Output
""
Explanation
3 removes b, 4 removes c, leaving nothing.
Example 2
Input
s = "abc"
Output
"abc"
Explanation
There are no digits, so nothing is removed.
Example 3
Input
s = "a1b2c3"
Output
""
Explanation
Each digit removes the closest remaining character to its left: 1 removes a, 2 removes b, and 3 removes c.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.