File tree Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Expand file tree Collapse file tree 2 files changed +24
-0
lines changed Original file line number Diff line number Diff line change
1
+ use crate :: solutions:: Solution ;
2
+
3
+ impl Solution {
4
+ pub fn clear_digits ( s : String ) -> String {
5
+ let mut stack = String :: new ( ) ;
6
+
7
+ for c in s. chars ( ) {
8
+ if c. is_ascii_digit ( ) {
9
+ stack. pop ( ) ;
10
+ } else {
11
+ stack. push ( c) ;
12
+ }
13
+ }
14
+
15
+ stack
16
+ }
17
+ }
18
+
19
+ #[ test]
20
+ fn test ( ) {
21
+ assert_eq ! ( Solution :: clear_digits( "abc" . to_owned( ) ) , "abc" ) ;
22
+ assert_eq ! ( Solution :: clear_digits( "cb34" . to_owned( ) ) , "" ) ;
23
+ }
Original file line number Diff line number Diff line change @@ -5,5 +5,6 @@ pub mod _0026_remove_duplicates_from_sorted_array;
5
5
pub mod _0027_remove_element;
6
6
pub mod _1848_minimum_distance_to_the_target_element;
7
7
pub mod _3046_split_the_array;
8
+ pub mod _3174_clear_digits;
8
9
9
10
pub struct Solution { }
You can’t perform that action at this time.
0 commit comments