Maximum Number of Words in a Sentence

Easy

Description

A sentence is a list of words separated by a single space. Given an array of sentences, return the maximum number of words that appear in a single sentence.

Examples

Input:sentences = ["alice and bob love leetcode","i think so too","this is great thanks very much"]
Output:6
Explanation:

Last sentence has 6 words.

Input:hello worldprogramming is fun and challengingcode
Output:5
Explanation:

The first sentence has 2 words, the second sentence has 5 words, and the third sentence has 1 word. The maximum is 5 words.

Input:welcome to the coding interviewgood luckyou can do it well today
Output:6
Explanation:

The first sentence has 5 words, the second sentence has 2 words, and the third sentence has 6 words. The maximum is 6 words.

Constraints

  • 1 ≤ sentences.length ≤ 100

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!