reverse letters keep numbers in place in java code example
Example: reverse letters keep numbers in place in java
public class Challenge {
public static String reverse(String str) {
char[] c = str.toCharArray();
int i = 0, j = c.length-1;
while(i< j){
while(Character.isDigit(c[i]))
i++;
while(Character.isDigit(c[j]))
j--;
char t = c[i];
c[i] = c[j];
c[j] = t;
i++;
j--;
}
return new String(c);
}
}