A field radio operator reads back every transmitted message as a confirmation echo. Protocol requires the echo to repeat each word letter-by-letter in reverse, so the sender can tell every character was received, while the words themselves must stay in their original left-to-right order with the exact same single-space separators.
Given the original dispatch, produce the confirmation echo.
A single line containing the string s.
A single line: s with the characters of each word reversed, in place, leaving word order and spacing unchanged.
1 <= length of s <= 50000s consists of printable ASCII characters.s are separated by exactly one space.s has no leading or trailing spaces.Example 1
Input
field radio echo test
Expected
dleif oidar ohce tset
Explanation
Each word is reversed independently while word order and single spaces stay the same: field -> dleif, radio -> oidar, echo -> ohce, test -> tset, giving "dleif oidar ohce tset".
Example 2
Input
signal
Expected
langis
Explanation
There is only one word, so the whole string is reversed: signal -> langis.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →