← All problems
Reverse a String
Easy
1 solved
Reverse a String
Given a single word S containing no spaces, print the word with its characters in reverse order.
For example, hello becomes olleh. A one-character word stays the same, and so does a palindrome like racecar.
Digits and mixed case are allowed and are simply reversed along with everything else.
Input
A single line containing the string S (no spaces).
Output
The characters of S in reverse order.
Constraints
1 <= length of S <= 100
Example 1
Input
hello
Output
olleh
Reading h-e-l-l-o backwards gives o-l-l-e-h.
Submit runs your code against 5 test cases — the 1 shown above plus 4 hidden ones covering the awkward cases. Run sample just tries the first example, which is usually what you want while you are still working it out.