Skip to content

Commit c9acdd8

Browse files
authored
Create replace-all-digits-with-characters.cpp
1 parent 196f8f5 commit c9acdd8

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Time: O(n)
2+
// Space: O(1)
3+
4+
class Solution {
5+
public:
6+
string replaceDigits(string s) {
7+
for (int i = 1; i < size(s); i += 2) {
8+
s[i] += s[i - 1] - '0';
9+
}
10+
return s;
11+
}
12+
};

0 commit comments

Comments
 (0)