class Solution {
public int numUniqueEmails(String[] emails) {
Set<String> s = new HashSet<String>();
for (String e: emails) {
int idx = e.indexOf("@");
String host = e.substring(idx, e.length());
String local = e.substring(0, idx);
int idx1 = local.indexOf("+");
if (idx1 >= 0) local = local.substring(0, idx1);
local = local.replaceAll("\\.", "");
s.add(local + host);
}
return s.size();
}
}
相关文章
- 03-27LeetCode解题报告—— Reverse Linked List II & Restore IP Addresses & Unique Binary Search Trees II
- 03-27LeetCode.927-独特邮箱地址(Unique Email Addresses)
- 03-27[leetcode]Unique Email Addresses
- 03-27929. Unique Email Addresses
- 03-27929. Unique Email Addresses*
- 03-27[LeetCode] 929. Unique Email Addresses_Easy tag: Hash
- 03-27[LeetCode] 929. Unique Email Addresses_Easy tag: Hash
- 03-27929. Unique Email Addresses