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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started