2284. Sender With Largest Word Count Medium

@problem@discussion
#Array#Hash Table#String#Counting



1/**
2 * [2284] Sender With Largest Word Count
3 *
4 * You have a chat log of n messages. You are given two string arrays messages and senders where messages[i] is a message sent by senders[i].
5 * A message is list of words that are separated by a single space with no leading or trailing spaces. The word count of a sender is the total number of words sent by the sender. Note that a sender may send more than one message.
6 * Return the sender with the largest word count. If there is more than one sender with the largest word count, return the one with the lexicographically largest name.
7 * Note:
8 * 
9 * 	Uppercase letters come before lowercase letters in lexicographical order.
10 * 	"Alice" and "alice" are distinct.
11 * 
12 *  
13 * Example 1:
14 * 
15 * Input: messages = ["Hello userTwooo","Hi userThree","Wonderful day Alice","Nice day userThree"], senders = ["Alice","userTwo","userThree","Alice"]
16 * Output: "Alice"
17 * Explanation: Alice sends a total of 2 + 3 = 5 words.
18 * userTwo sends a total of 2 words.
19 * userThree sends a total of 3 words.
20 * Since Alice has the largest word count, we return "Alice".
21 * 
22 * Example 2:
23 * 
24 * Input: messages = ["How is leetcode for everyone","Leetcode is useful for practice"], senders = ["Bob","Charlie"]
25 * Output: "Charlie"
26 * Explanation: Bob sends a total of 5 words.
27 * Charlie sends a total of 5 words.
28 * Since there is a tie for the largest word count, we return the sender with the lexicographically larger name, Charlie.
29 *  
30 * Constraints:
31 * 
32 * 	n == messages.length == senders.length
33 * 	1 <= n <= 10^4
34 * 	1 <= messages[i].length <= 100
35 * 	1 <= senders[i].length <= 10
36 * 	messages[i] consists of uppercase and lowercase English letters and ' '.
37 * 	All the words in messages[i] are separated by a single space.
38 * 	messages[i] does not have leading or trailing spaces.
39 * 	senders[i] consists of uppercase and lowercase English letters only.
40 * 
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/sender-with-largest-word-count/
45// discuss: https://leetcode.com/problems/sender-with-largest-word-count/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50    pub fn largest_word_count(messages: Vec<String>, senders: Vec<String>) -> String {
51        String::new()
52    }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_2284() {
63    }
64}
65


Back
© 2025 bowen.ge All Rights Reserved.