#K88022. Reverse Sentence Preserving Spaces
Reverse Sentence Preserving Spaces
Reverse Sentence Preserving Spaces
This problem requires you to reverse a given sentence while preserving the positions of the spaces. In other words, only the non‐space characters should be reversed. For example, if the input is "hello world", the expected output is "dlrow olleh". This means that even though the characters are reversed, the spaces remain in their original positions.
Your program should read the sentence from standard input (stdin) and output the transformed sentence to standard output (stdout). Handle cases such as sentences with multiple spaces, sentences with only spaces, and even empty strings.
inputFormat
A single line containing a sentence. The sentence may include letters, spaces, and other printable characters. The input line should be read from standard input (stdin).
outputFormat
Output a single line which is the reversed version of the input sentence with the original spaces preserved. The result should be printed to standard output (stdout).
## samplehello
olleh