Implement a function that reorders spaces in a given string of text. The function should adjust the spaces between words such that they are evenly distributed, and any remaining spaces should be added to the end of the string.
Function Signature:
python
def reorder_spaces(text: str) -> str:
Requirements:
Input:
A single string text which may contain words separated by spaces. The text may have leading, trailing, and multiple spaces between words.
The input string will have a length of at least 1 character.
Output:
The function should return a new string where:
The words from the input string are reordered such that they are spaced evenly.
If there are leftover spaces after equal distribution, they should be added to the end of the string.
Behaviors:
If the input string consists of a single word, the output should be that word followed by all the spaces present in the input.
If there are no spaces in the input, the output should be the original text as there are no spaces to reorder.
Example:
python
assert reorder_spaces(" this is a test ") == "this is a test "
assert reorder_spaces("a b") == "a b "
assert reorder_spaces(" ") == " "
Implementation Location:
The solution must be written in a file called /app/solution.py.