Maximum Number of Words Found in Sentences

A sentence is a list of words separated by a single space with no leading or trailing spaces. You are given an array of sentences, and the task is to determine the maximum number of words contained in a single sentence.

Constraints

  • 1 <= sentences.length <= 100
  • 1 <= sentences[i].length <= 100
  • sentences[i] consists only of lowercase English letters and ' ' only.
  • sentences[i] does not have leading or trailing spaces.
  • All the words in sentences[i] are separated by a single space.
Saving… · 2 lines
class Solution:
def maximumNumberOfWordsInSentence(self, sentences: List[str]) -> int:
Console

Click Run to execute sample tests.