Watch 10 video solutions for Reverse Words in a String III, a easy level problem involving Two Pointers, String. This walkthrough by Knowledge Center has 27,654 views views. Want to try solving it yourself? Practice on FleetCode or read the detailed text solution.
Given a string s, reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Example 1:
Input: s = "Let's take LeetCode contest" Output: "s'teL ekat edoCteeL tsetnoc"
Example 2:
Input: s = "Mr Ding" Output: "rM gniD"
Constraints:
1 <= s.length <= 5 * 104s contains printable ASCII characters.s does not contain any leading or trailing spaces.s.s are separated by a single space.