A mountaineering expedition's base camp keeps a log of n radio dispatch messages sent during the climb. Each message is one line of text made up of one or more words separated by exactly one space, with no leading or trailing spaces and no other whitespace inside a word. Determine the maximum number of words that appear in any single dispatch message in the log.
Line 1 contains a single integer n, the number of dispatch messages. Each of the next n lines contains one dispatch message: a non-empty string of English letters (upper or lower case) with words separated by single spaces, and no leading or trailing spaces.
Print a single integer: the largest number of words found in any one of the n dispatch messages.
Example 1
Input
2 camp secure all clear resupply requested
Expected
4
Explanation
The first dispatch has 4 words (camp, secure, all, clear) and the second has 2 words (resupply, requested). The maximum across all dispatches is 4.
Example 2
Input
3 go storm warning issued for ridge camp hold position
Expected
6
Explanation
The first dispatch has 1 word, the second has 6 words (storm, warning, issued, for, ridge, camp), and the third has 2 words. The maximum is 6.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →