Tap here to switch tabs
Problem
Submissions

Problem: Reverse Words in a String III

med
30 min
Try to solve the Reverse Words in a String III problem.

Statement

Given a string s, reverse the characters of each word in s while preserving the order of the words and the spaces between them.

Return the resulting string.

Note: A word is a maximal substring of non space characters.

Constraints:

  • 1≤1 \leq s.length ≤5imes104\leq 5 imes 10^4

  • s contains printable ASCII characters.

  • s has no leading or trailing spaces.

  • s contains at least one word.

  • Every word in s is separated by exactly one space.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Reverse Words in a String III

med
30 min
Try to solve the Reverse Words in a String III problem.

Statement

Given a string s, reverse the characters of each word in s while preserving the order of the words and the spaces between them.

Return the resulting string.

Note: A word is a maximal substring of non space characters.

Constraints:

  • 1≤1 \leq s.length ≤5imes104\leq 5 imes 10^4

  • s contains printable ASCII characters.

  • s has no leading or trailing spaces.

  • s contains at least one word.

  • Every word in s is separated by exactly one space.