Skip to content

Commit a7de6da

Browse files
authored
Create 3174. Clear Digits
1 parent 30cbd1d commit a7de6da

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

3174. Clear Digits

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Solution {
2+
public:
3+
string clearDigits(string s) {
4+
int i=0;
5+
while(i<s.length()) {
6+
if('0' <= s[i] && s[i] <= '9') {
7+
s.erase(i,1); // erase the digit from the string
8+
s.erase(i-1,1); // erase the alphabet from the string
9+
i--;
10+
}
11+
else {
12+
i++;
13+
}
14+
}
15+
16+
17+
return s;
18+
}
19+
};

0 commit comments

Comments
 (0)