2378. Sender With Largest Word Count
My accepted Python solution to LeetCode problem 2378, Sender With Largest Word Count, running in 37ms.
- Difficulty: Medium
- Python
- Runtime 37ms
- Memory 21.7MB
- Updated
Read the problem on LeetCode View on GitHub
The problem statement is LeetCode’s and stays on their site. What follows is my accepted solution.
Python
Accepted on LeetCode — runtime 37ms, memory 21.7MB, accepted 2025-12-29.
class Solution:
def largestWordCount(self, messages: List[str], senders: List[str]) -> str:
word_count = {}
for message, sender in zip(messages, senders):
count = len(message.split())
word_count[sender] = word_count.get(sender, 0) + count
max_count = max(word_count.values())
result = ""
for sender, count in word_count.items():
if count == max_count and sender > result:
result = sender
return result