#C9851. Reverse Letters in Each Word Maintaining Word Order

    ID: 53990 Type: Default 1000ms 256MiB

Reverse Letters in Each Word Maintaining Word Order

Reverse Letters in Each Word Maintaining Word Order

This problem requires you to reverse the letters in each word of a given string, while maintaining the original order of the words and the positions of all spaces. For example, if the input is hello world!, the output should be olleh !dlrow. The reversal of letters in each word is defined as follows: if a word is represented as \( w = w_1w_2\ldots w_n \), then its reversed version is \( w_n\ldots w_2w_1 \). All spaces are preserved exactly as in the input.

Note: Any punctuation, digits, or special characters within a word should be reversed along with the letters.

inputFormat

The input consists of a single line containing a string s. The string may include letters, digits, punctuation, and spaces. Read the entire content from standard input.

outputFormat

Output the transformed string where the letters in each word are reversed, but the positions of the spaces remain the same. Write the result to standard output.

## sample