Reverse Words in a String III
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
Given a string s that contains words separated by single spaces, reverse the characters of **each individual word** while keeping the words in their original order. The spacing between words must be preserved exactly.
In other words, you flip every word in place. A word that reads "hello" becomes "olleh", but its position in the sentence does not change.
You may assume s contains no leading or trailing spaces and that exactly one space separates any two adjacent words.
Return the resulting string.
Examples
Constraints
- 1 <= s.length <= 5 * 10^4
- `s` contains printable ASCII characters and spaces.
- `s` does not contain leading or trailing spaces.
- All words in `s` are separated by exactly one space.
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.