Problem of the day
If the given string is: STR = "abcde". You have to print the string "edcba".
Try to solve the problem in O(1) space complexity.
The first line of input contains a single integer 'T', representing the number of test cases or queries to be run.
Then the 'T' test cases follow.
The first and only line of each test case contains a string 'STR'.
For each test case, print a single line containing a single string denoting the reverse of the given string 'STR'.
The output of each test case will be printed in a separate line.
You are not required to print the expected output, it has already been taken care of. Just implement the function.
1 ≤ T ≤ 10
1 ≤ |STR| ≤ 10 ^ 5
Where |STR| is the length of the string STR.
Time limit: 1 sec.
3
abcde
coding
hello1
edcba
gnidoc
1olleh
For the first test case, STR = "abcde". We need to reverse the string, that is the first element becomes the last element and the last element becomes the first element, the second element becomes the second last element and the second last element becomes the second element and so on. So we get, "edcba".
3
a
1det@Z
$1xYuP
a
Z@ted1
PuYx1$