Answers for "reverse letters keep numbers in place in java"

0

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);
 

	}
}
Posted by: Guest on February-23-2021

Code answers related to "reverse letters keep numbers in place in java"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language