#K61587. Reverse Words
Reverse Words
Reverse Words
You are given a string S
. Your task is to output a new string in which the order of words is reversed.
A word is defined as a non-empty sequence of characters separated by whitespace. If the input string contains only spaces or is empty, output an empty string.
Note: In this problem, multiple consecutive whitespace characters should be treated as a single delimiter.
For example, if S = "hello world from coding assessment"
, then the output should be "assessment coding from world hello"
.
inputFormat
The input is provided via standard input (stdin) and consists of a single line containing the string S
which may include multiple words separated by spaces.
outputFormat
The output should be printed to standard output (stdout) and consists of a single line containing the words of S
in reversed order separated by a single space.
hello
hello