Reverse Words in a Sentence

easy

100 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
Discussion

No comments yet — ask a question or share a hint.

Log in to join the discussion.

Log in to submit a solution.