We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6b7f7bb commit 6677a76Copy full SHA for 6677a76
scripts/algorithms/R/Replace All Digits with Characters/Replace All Digits with Characters.java
@@ -1,20 +1,20 @@
1
+// Runtime: 2 ms (Top 43.86%) | Memory: 42.6 MB (Top 27.39%)
2
class Solution {
3
public String replaceDigits(String s) {
4
char[] str = s.toCharArray();
-
5
+
6
for(int i=0;i<str.length;i++){
7
if(Character.isDigit(str[i])){
8
str[i] = shift(str[i-1],str[i]);
9
}
10
11
return String.valueOf(str);
12
13
14
char shift(char letter, char number){
15
int a = Integer.parseInt(String.valueOf(number));
16
int asci = (int)letter;
17
char c = (char)(asci + a);
18
return c;
19
20
-}
+}
0 commit comments