Reverse Words in a String III
String Simulation
Problem
Given a string, you need to reverse the order of characters in each word within a sentence while still preserving whitespace and initial word order.
Note: In the string, each word is separated by single space and there will not be any extra space in the string.
For example:
Thought Process
This question is similar to Reverse Words in a String except here we aren't reversing the words of the sentence, only the letters of each word
Solution
Time Complexity
Time: O(n)
Space: O(1)
Last updated
Was this helpful?