Reverse Words in a Sentence
easy100 pts · Time limit 2000 ms · Memory limit 256 MB · Leaderboard · strings
Given a sentence, print the words in reverse order, separated by a single space. Leading/trailing extra spaces should be collapsed.
Input Format
A single line containing the sentence.
Output Format
The words of the sentence, reversed, space-separated.
Constraints
1 <= sentence length <= 10^4
Sample 1
Input
the sky is blue
Output
blue is sky the
Sample 2
Input
hello world
Output
world hello
Log in to submit a solution.