Skip to content

Commit 3806c9f

Browse files
committed
Time: 15 ms (6.39%), Space: 43 MB (8.93%) - LeetHub
1 parent e09ee65 commit 3806c9f

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution {
2+
public String replaceDigits(String s) {
3+
String answer = "";
4+
for(int i = 0; i < s.length(); i++){
5+
if(Character.isAlphabetic(s.charAt(i))){
6+
answer += s.charAt(i);
7+
//System.out.println(i + 1);
8+
if(i + 1 < s.length()){
9+
if(Character.isDigit(s.charAt(i + 1))){
10+
answer += (char)((int)s.charAt(i) + (s.charAt(i + 1) - '0'));
11+
}
12+
}
13+
14+
}
15+
16+
}
17+
18+
return answer;
19+
}
20+
}

0 commit comments

Comments
 (0)