We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 30cbd1d commit a7de6daCopy full SHA for a7de6da
3174. Clear Digits
@@ -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