929. Unique Email Addresses Easy

@problem@discussion
#Array#Hash Table#String



1/**
2 * [929] Unique Email Addresses
3 *
4 * Every valid email consists of a local name and a domain name, separated by the '@' sign. Besides lowercase letters, the email may contain one or more '.' or '+'.
5 * 
6 * 	For example, in "[email protected]", "alice" is the local name, and "leetcode.com" is the domain name.
7 * 
8 * If you add periods '.' between some characters in the local name part of an email address, mail sent there will be forwarded to the same address without dots in the local name. Note that this rule does not apply to domain names.
9 * 
10 * 	For example, "[email protected]" and "[email protected]" forward to the same email address.
11 * 
12 * If you add a plus '+' in the local name, everything after the first plus sign will be ignored. This allows certain emails to be filtered. Note that this rule does not apply to domain names.
13 * 
14 * 	For example, "[email protected]" will be forwarded to "[email protected]".
15 * 
16 * It is possible to use both of these rules at the same time.
17 * Given an array of strings emails where we send one email to each emails[i], return the number of different addresses that actually receive mails.
18 *  
19 * Example 1:
20 * 
21 * Input: emails = ["[email protected]","[email protected]","[email protected]"]
22 * Output: 2
23 * Explanation: "[email protected]" and "[email protected]" actually receive mails.
24 * 
25 * Example 2:
26 * 
27 * Input: emails = ["[email protected]","[email protected]","[email protected]"]
28 * Output: 3
29 * 
30 *  
31 * Constraints:
32 * 
33 * 	1 <= emails.length <= 100
34 * 	1 <= emails[i].length <= 100
35 * 	emails[i] consist of lowercase English letters, '+', '.' and '@'.
36 * 	Each emails[i] contains exactly one '@' character.
37 * 	All local and domain names are non-empty.
38 * 	Local names do not start with a '+' character.
39 * 	Domain names end with the ".com" suffix.
40 * 
41 */
42pub struct Solution {}
43
44// problem: https://leetcode.com/problems/unique-email-addresses/
45// discuss: https://leetcode.com/problems/unique-email-addresses/discuss/?currentPage=1&orderBy=most_votes&query=
46
47// submission codes start here
48
49impl Solution {
50    pub fn num_unique_emails(emails: Vec<String>) -> i32 {
51        0
52    }
53}
54
55// submission codes end
56
57#[cfg(test)]
58mod tests {
59    use super::*;
60
61    #[test]
62    fn test_929() {
63    }
64}
65


Back
© 2025 bowen.ge All Rights Reserved.