Reverse Only Letters Problem Statement
You are given a string S
. The task is to reverse the letters of the string while keeping non-alphabet characters in their original position.
Example:
Input:
S = "a-bcd"
Output:
"d-cba"
Explanation:
In the string, only the letters 'a', 'b', 'c', and 'd' are reversed, while the '-' character remains in place.
Constraints:
1 ≤ T ≤ 10
0 ≤ |S| ≤ 5000
- Time Limit: 1 Sec
Input:
The first line of the input contains ‘T’ denoting the number of test cases.
The first line of each test case contains a string ‘S’.
Output:
For every test case, print the reversed string on a new line.
Note:
You do not need to print anything; it has already been taken care of. Just implement the given function.
Be the first one to answer
Add answer anonymously...
Top PayU Payments Software Engineer interview questions & answers
Popular interview questions of Software Engineer
Top HR questions asked in PayU Payments Software Engineer
>
PayU Payments Software Engineer Interview Questions
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app