#K77627. Reverse Words in a String
Reverse Words in a String
Reverse Words in a String
You are given a string s
that contains words separated by spaces. Your task is to reverse the order of the words in the string while keeping the characters inside each word intact. Extra spaces should be ignored. For example, for the input hello world
, the output should be world hello
.
Note that the input string may include punctuation and additional spaces. Make sure your solution correctly handles these cases.
inputFormat
The input consists of a single line string s
. It may have leading or trailing spaces and multiple spaces between words.
outputFormat
Output the string with the order of words reversed. The internal order of characters in each word must remain unchanged.
## samplehello
hello