1451. Rearrange Words in a Sentence
https://leetcode.com/problems/rearrange-words-in-a-sentence
Description
Given a sentence text
(A sentence is a string of space-separated words) in the following format:
First letter is in upper case.
Each word in
text
are separated by a single space.
Your task is to rearrange the words in text such that all words are rearranged in an increasing order of their lengths. If two words have the same length, arrange them in their original order.
Return the new text following the format shown above.
Example 1:
Example 2:
Example 3:
Constraints:
text
begins with a capital letter and then contains lowercase letters and single space between words.1 <= text.length <= 10^5
ac
Previous1450. Number of Students Doing Homework at a Given TimeNext1452. People Whose List of Favorite Companies Is Not a Subset of Another List
Last updated