Skip to content

Commit 3c1448e

Browse files
authored
Create 3174. Clear Digits (#712)
2 parents 30cbd1d + a7de6da commit 3c1448e

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)