Tap here to switch tabs
Problem
Submissions

Problem: Rearrange Words in a Sentence

Try to solve the Rearrange Words in a Sentence problem.

Statement

Given a sentence text consisting of words separated by single spaces, rearrange the words so that they are ordered in non-decreasing order of their lengths. If two or more words have the identical length, preserve their original relative order.

The resulting sentence must have only the first character capitalized, with all subsequent characters in lowercase.

Constraints:

  • text begins with a capital letter and contains only lowercase English letters and single spaces separating words.

  • 1≤1 \leq text.length ≤105\leq 10^5

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Rearrange Words in a Sentence

Try to solve the Rearrange Words in a Sentence problem.

Statement

Given a sentence text consisting of words separated by single spaces, rearrange the words so that they are ordered in non-decreasing order of their lengths. If two or more words have the identical length, preserve their original relative order.

The resulting sentence must have only the first character capitalized, with all subsequent characters in lowercase.

Constraints:

  • text begins with a capital letter and contains only lowercase English letters and single spaces separating words.

  • 1≤1 \leq text.length ≤105\leq 10^5