1592. Rearrange Spaces Between Words
Description
**Input:** text = " this is a sentence "
**Output:** "this is a sentence"
**Explanation:** There are a total of 9 spaces and 4 words. We can evenly divide the 9 spaces between the words: 9 / (4-1) = 3 spaces.**Input:** text = " practice makes perfect"
**Output:** "practice makes perfect "
**Explanation:** There are a total of 7 spaces and 3 words. 7 / (3-1) = 3 spaces plus 1 extra space. We place this extra space at the end of the string.**Input:** text = "hello world"
**Output:** "hello world"**Input:** text = " walks udp package into bar a"
**Output:** "walks udp package into bar a "ac
Last updated