LeetCode --- 1592. Rearrange Spaces Between Words 解题报告

Posted 杨鑫newlfe

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了LeetCode --- 1592. Rearrange Spaces Between Words 解题报告相关的知识,希望对你有一定的参考价值。

You are given a string text of words that are placed among some number of spaces. Each word consists of one or more lowercase English letters and are separated by at least one space. It\'s guaranteed that text contains at least one word.

Rearrange the spaces so that there is an equal number of spaces between every pair of adjacent words and that number is maximized. If you cannot redistribute all the spaces equally, place the extra spaces at the end, meaning the returned string should be the same length as text.

Return the string after rearranging the spaces.

Example 1:

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 betw

以上是关于LeetCode --- 1592. Rearrange Spaces Between Words 解题报告的主要内容,如果未能解决你的问题,请参考以下文章

LeetCode --- 1592. Rearrange Spaces Between Words 解题报告

LeetCode --- 1592. Rearrange Spaces Between Words 解题报告

LeetCode 1592 重新排列单词间的间隔[字符串] HERODING的LeetCode之路

Database,Uva1592

CodeForces - 1592A Gamer Hemose排序

CodeForces - 1592A Gamer Hemose排序