#B2122. Restore Reversed Words
Restore Reversed Words
Restore Reversed Words
Little Ming has a quirky habit of writing words in reverse order. For example, he writes hello
as olleh
. Given a sentence where every word is reversed, your task is to restore each word to its correct order.
Note: The input consists of a single line containing one or more words. Words are separated by spaces.
inputFormat
The input is a single line containing a sentence with each word reversed. For example: olleh dlrow
.
Input Format:
Line 1: A string S representing the sentence with reversed words.
outputFormat
Output the sentence with each word corrected (i.e. written in the proper order). The words should be separated by a single space.
Output Format:
A single line containing the restored sentence.
sample
olleh
hello