Tap here to switch tabs
Problem
Submissions

Problem: Sender With Largest Word Count

med
30 min
Try to solve the Sender With Largest Word Count problem.

Statement

You are given two string arrays, messages and senders, each of length n. The iextthi^{ ext{th}} message messages[i] was sent by the sender senders[i].

A message is a string of words separated by single spaces, with no leading or trailing spaces. The word count of a message is defined as the total number of words it contains.

Return the name of the sender with the largest total word count. If multiple senders share the maximum total word count, return the sender with the lexicographically largest name.

Note: Lexicographical order is based on ASCII values, where uppercase English letters are considered smaller than lowercase English letters.

Constraints:

  • n ==== messages.length ==== senders.length

  • 1≤1 \leq n ≤104\leq 10^4

  • 1≤1 \leq messages[i].length ≤100\leq 100

  • 1≤1 \leq senders[i].length ≤10\leq 10

  • messages[i] consists of uppercase and lowercase English letters and ' '.

  • All the words in messages[i] are separated by a single space.

  • messages[i] does not have leading or trailing spaces.

  • senders[i] consists of uppercase and lowercase English letters only.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Sender With Largest Word Count

med
30 min
Try to solve the Sender With Largest Word Count problem.

Statement

You are given two string arrays, messages and senders, each of length n. The iextthi^{ ext{th}} message messages[i] was sent by the sender senders[i].

A message is a string of words separated by single spaces, with no leading or trailing spaces. The word count of a message is defined as the total number of words it contains.

Return the name of the sender with the largest total word count. If multiple senders share the maximum total word count, return the sender with the lexicographically largest name.

Note: Lexicographical order is based on ASCII values, where uppercase English letters are considered smaller than lowercase English letters.

Constraints:

  • n ==== messages.length ==== senders.length

  • 1≤1 \leq n ≤104\leq 10^4

  • 1≤1 \leq messages[i].length ≤100\leq 100

  • 1≤1 \leq senders[i].length ≤10\leq 10

  • messages[i] consists of uppercase and lowercase English letters and ' '.

  • All the words in messages[i] are separated by a single space.

  • messages[i] does not have leading or trailing spaces.

  • senders[i] consists of uppercase and lowercase English letters only.