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β.
For every test case, we need to print the reversed string in a new line.
You do not need to print anything, it has already been taken care of. Just implement the given function.
1 <= T <= 10
0 <= |S| <= 5000
Where |S| denotes the length of string 'S'.
Time Limit: 1 Sec
Approach: Just like in order to reverse a string βSβ = βabcdβ, we can can swap(S[0], S[3]) and swap(S[1],S[2]) to get new string βdcbaβ.
Similarly in this problem, we do the same using two pointers while ignoring the non-letter characters.
Eg: S = βa-bcdβ we swap(S[0], S[4]) and swap(S[2], S[3]) to get the result.
Algorithm: