3174. Clear Digits Easy
1/**
2 * [3174] Clear Digits
3 *
4 * You are given a string s.
5 * Your task is to remove all digits by doing this operation repeatedly:
6 *
7 * Delete the first digit and the closest non-digit character to its left.
8 *
9 * Return the resulting string after removing all digits.
10 *
11 * <strong class="example">Example 1:
12 * <div class="example-block">
13 * Input: <span class="example-io">s = "abc"</span>
14 * Output: <span class="example-io">"abc"</span>
15 * Explanation:
16 * There is no digit in the string.<!-- notionvc: ff07e34f-b1d6-41fb-9f83-5d0ba3c1ecde -->
17 * </div>
18 * <strong class="example">Example 2:
19 * <div class="example-block">
20 * Input: <span class="example-io">s = "cb34"</span>
21 * Output: <span class="example-io">""</span>
22 * Explanation:
23 * First, we apply the operation on s[2], and s becomes "c4".
24 * Then we apply the operation on s[1], and s becomes "".
25 * </div>
26 *
27 * Constraints:
28 *
29 * 1 <= s.length <= 100
30 * s consists only of lowercase English letters and digits.
31 * The input is generated such that it is possible to delete all digits.
32 *
33 */
34pub struct Solution {}
35
36// problem: https://leetcode.com/problems/clear-digits/
37// discuss: https://leetcode.com/problems/clear-digits/discuss/?currentPage=1&orderBy=most_votes&query=
38
39// submission codes start here
40
41impl Solution {
42 pub fn clear_digits(s: String) -> String {
43 String::new()
44 }
45}
46
47// submission codes end
48
49#[cfg(test)]
50mod tests {
51 use super::*;
52
53 #[test]
54 fn test_3174() {
55 }
56}
57
Back
© 2025 bowen.ge All Rights Reserved.