2284. Sender With Largest Word Count

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2284

class Solution:
    def largestWordCount(self, messages: List[str], senders: List[str]) -> str:
        cnt = Counter()
        for msg, sender in zip(messages, senders):
            cnt[sender] += msg.count(' ') + 1
        res = ''
        for sender, v in cnt.items():
            if cnt[res] < v or (cnt[res] == v and res < sender):
                res = sender
        return res