As reported: Oracle Senior Application Engineer (Java) walk-in drive, Gandhinagar, round 1, May 2025 — reverse each word of a string while keeping the spaces in place. Reversing each word of a sentence in Java also came up in an Oracle IC2 hiring-manager round (Mar 2025).
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 = "God Ding"
Output: "doG gniD"
Constraints:
- 1 <= s.length <= 5 * 10^4
- s contains printable ASCII characters.
- s does not contain any leading or trailing spaces.
- There is at least one word in s.
- All the words in s are separated by a single space.
This is LeetCode 557 — Reverse Words in a String III.
Code runner format: LeetCode's test-case format, one JSON value per line (one line per argument). Implement reverseWords(s); the harness prints the result as JSON.