Reverse a String
Practice this coding question on Coding Gurukul.
Problem statement
A puzzle printer stores a clue as a sequence of letters. For a mirror-reading round, it must print the characters in the opposite order while keeping their original case. Your task Reverse the given string. Important details Every character appears once in the output for each occurrence in the input. Do not alphabetize letters or change uppercase letters to lowercase. The input has no spaces, so the entire token is the clue. A one-character clue is unchanged. The output must contain only the reversed text. Worked example The clue AbcD becomes DcbA: the last character moves first and the first moves last.
Input format
One nonempty string s.
Output format
Print s in reverse order.
Constraints
1 <= length(s) <= 100000; s contains English letters.
Sample input
AbcD
Sample output
DcbA
Sign in to run or submit a solution in C++, Java or Python.