| { |
| "id": 3447, |
| "name": "clear-digits", |
| "difficulty": "Easy", |
| "link": "https://leetcode.com/problems/clear-digits/", |
| "date": "2024-05-25", |
| "task_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. **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` consists only of lowercase English letters and digits. The input is generated such that it is possible to delete all digits.", |
| "test_case": [ |
| { |
| "label": "Example 1", |
| "input": "s = \"abc\"", |
| "output": "\"abc\" " |
| }, |
| { |
| "label": "Example 2", |
| "input": "s = \"cb34\"", |
| "output": "\"\" " |
| } |
| ], |
| "constraints": [ |
| "Delete the first digit and the closest non-digit character to its left.", |
| "1 <= s.length <= 100", |
| "s consists only of lowercase English letters and digits.", |
| "The input is generated such that it is possible to delete all digits." |
| ], |
| "python_template": "class Solution(object):\n def clearDigits(self, s):\n \"\"\"\n :type s: str\n :rtype: str\n \"\"\"\n ", |
| "java_template": "class Solution {\n public String clearDigits(String s) {\n \n }\n}", |
| "metadata": { |
| "func_name": "clearDigits" |
| } |
| } |