Skip to content

Practice Sender With Largest Word Count

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#2284
LeetCode Problem

Sender With Largest Word Count

Problem Statement

messages[i] belongs to senders[i]. Words are separated by single spaces without leading or trailing spaces. Sum word counts across all messages of each sender and return the sender with the largest total. Break ties by lexicographically largest case-sensitive name, with uppercase letters ordered before lowercase letters.

Source: Sender With Largest Word Count on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
messages = ["Hello userTwooo","Hi userThree","Wonderful day Alice","Nice day userThree"], senders = ["Alice","userTwo","userThree","Alice"]
Output
"Alice"

# Example 2

Input
messages = ["How is leetcode for everyone","Leetcode is useful for practice"], senders = ["Bob","Charlie"]
Output
"Charlie"

Constraints

n == messages.length == senders.length
1 <= n <= 10^4
1 <= messages[i].length <= 100
1 <= senders[i].length <= 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.

Related LeetCode Problems

Practice more problems similar to Sender With Largest Word Count.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.