19. Word Reverse

Difficulty: 

Given a string, we would like to reverse the letters in each word while maintaining the original order of words, spaces and punctuation. Words are separated by spaces and punctuation marks, and there are no numbers. The words consist of lower or upper case letters (so no hyphens), and the case of letters should be preserved in the final answer.

For example, This IS a word-teSt,yo! should turn into sihT SI a dorw-tSet,oy!.

Avoid using tokenizers (e.g. split in JavaScript strings).

Input:

wordReverse("This IS  a word-teSt,yo!");

Output:

"sihT SI  a drow-tSet,oy!"

Time Limit:

1000 (ms)

Hints (hover to see):

  • Hint #1
  • Hint #2



Results

ProblemsAcceptedWrongTimed OutError
150000

Input:

Expected Output:

Output: