Question: Reverse a string without affecting special characters Given a string, that contains special character together with alphabets (a to z and A to Z), reverse

Reverse a string without affecting special characters

Given a string, that contains special character together with alphabets (a to z and A to Z), reverse the string in a way that special characters are not affected.

Input: str = "a,b$c"

Output: str = "c,b$a"

Note that $ and , are not moved anywhere. Only subsequence "abc" is reversed.

Input: str = "Ab,c,de!$"

Output: str = "ed,c,bA!$"

----------------------------

class Main { //your main method public static void main(String[] args) { } // you will have to implement Utils class with its method reverseLetters

}

------------------------

public class Utils{ public static String reverseLetters(String word){ //your code here } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Finance Questions!