1451. Rearrange Words in a Sentence

Обновлено: 2024-03-12
1 мин
[]

Содержание

LeetCode problem 1451

class Solution:
    def arrangeWords(self, text: str) -> str:
        words = text.split()
        words[0] = words[0].lower()
        words.sort(key=len)
        words[0] = words[0].title()
        return " ".join(words)