Wordiest Sentence
Imagine you need to quickly find which sentence in a list contains the most words. Write a function max_words that receives a list of sentences where words are separated by single spaces. Count the words in each sentence. Return the largest word count.
Примеры
Ввод
["alice and bob love leetcode", "i think so too", "this is great thanks very much"]Вывод
6Ввод
["please wait", "continue to fight", "continue to win"]Вывод
3Ввод
["one"]Вывод
1Нужно реализовать
def max_words(sentences: list[str]) -> int:
Теги
stringsarray
Prijavite se za ogled zgodovine oddaj
PrijavaPrijavite se za uporabo mentorja UI
PrijavaVisible tests
1
Input
["alice and bob love leetcode","i think so too","this is great thanks very much"]Expected
62
Input
["please wait","continue to fight","continue to win"]Expected
33
Input
["one"]Expected
14
Input
["a b c d e"]Expected
55
Input
[]Expected
06
Input
["x","y z"]Expected
2Focus radio
Paused · SomaFM · Fluid