Question

LeetCode #557

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.

Pseudo code

  1. split a sentence into an array of words
  2. split each word into an array of letters
  3. reverse the letter array
  4. rejoin letters into strings
  5. rejoin strings into a sentence

Playground

See the Pen #557 Reverse Words in a String III by Cherry Wang (@chryw) on CodePen.