#3174

Clear Digits

easy · 82.7% accepted · 694 likes · top 94%

string · stack · simulation

⊣ practice⊣ open on leetcode ↗

Description

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.

Note that the operation cannot be performed on a digit that does not have any non-digit character to its left.

Solution