Easy

Quiz

#557 Reverse Words in a String III

APPROACH

Given a string s representing a sentence, reverse the characters within each individual word while keeping the words themselves in their original order and preserving all spacing.

Example 1:

Input: s = "Let's take LeetCode contest"
Output: "s'teL ekat edoCteeL tsetnoc"

Example 2:

Input: s = "Mr Ding"
Output: "rM gniD"
1 of 4
1:00

What is the optimal approach for this problem?