All tasks
Mediumstrings

Reverse Word Order

Time limit 2 s · Memory 64 MBAcceptance: —Solved by: 0

Statement

One line contains words separated by single spaces. Print the words in reverse order separated by single spaces. The letters inside each word keep their order.

Examples

Example 1
Input
hello world
Output
world hello
Example 2
Input
a b c
Output
c b a

Constraints

  • Line length is between 1 and 10^5
  • There is at least one word
Solve this task to unlock the editorial.

AI tutor

Stuck? Get a nudge — the tutor explains the idea, it never hands you the solution.