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 35a2f55 commit 2fdbcabCopy full SHA for 2fdbcab
Easy/Replace All Digits with Characters.java
@@ -0,0 +1,11 @@
1
+class Solution {
2
+ public String replaceDigits(String s) {
3
+ StringBuilder sb = new StringBuilder();
4
+ int n = s.length();
5
+ for (int i = 1; i < n; i += 2) {
6
+ char c = s.charAt(i - 1);
7
+ sb.append(c).append((char) (((int) c) + Character.getNumericValue(s.charAt(i))));
8
+ }
9
+ return n % 2 != 0 ? sb.append(s.charAt(n - 1)).toString() : sb.toString();
10
11
+}
0 commit comments