shlogg · Early preview
Md Ariful Haque @mah-shamim

Clear Digits From String In O(n) Time Complexity

Clear Digits: Remove all digits from a string by deleting each digit and its closest non-digit char to left. Use stack to track non-digits & pop top element when digit encountered.

3174. Clear Digits
Difficulty: Easy
Topics: String, Stack, Simulation
You are given a string s.
Your task is to remove all digits by doing this operation repeatedly:

Delete the first digit and the closest non-digit character to its left.

Return the resulting string after removing all digits.
Example 1:

Input: s = "abc"
Output: "abc"
Explanation: There is no digit in the string.

Example 2:

Input: s = "cb34"
Output: ""
Explanation:

First, we apply the operation on s[2], and s becomes "c4".
Then we apply the operation on s[1], and s becomes "".



Constraints:

1 <= s.length <= 100
s consis...