leetcode 929. Unique Email Addresses

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();
    }
}
上一篇:输入一个十六进制数a,和一个八进制数b,输出a+b的十进制结果


下一篇:C#发送字符串转字节含空格与0x需删去