Reverse the Words in a String
Problem Description​
Write a function that returns a string with each of its words reversed but in the original order, without using a loop.
Input​
- A single string.
Output​
- A string with words in the same order but with the letters in each word reversed.
Constraints​
- The function should not use a
for
loop.
Example​
Input:
"Swift Coding Challenges"Output:
"tfiwS gnidoC segnellahC"Explanation:
The words "Swift", "Coding", and "Challenges" are reversed individually to "tfiwS", "gnidoC", and "segnellahC" respectively, but remain in the same order.
Input:
"The quick brown fox"Output:
"ehT kciuq nworb xof"Explanation:
The words "The", "quick", "brown", and "fox" are reversed individually to "ehT", "kciuq", "nworb", and "xof" respectively, but remain in the same order.