Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Investments An Introduction

Authors: Herbert B Mayo

10th Edition

0538452099, 9780538452090

More Books

Students also viewed these Finance questions

Question

3 How to plan for the research presentation.

Answered: 1 week ago