package leetcode;

/**
 * https://leetcode.com/problems/unique-email-addresses/
 */
public class Problem929 {
    public int numUniqueEmails(String[] emails) {
        // TODO
        return 0;
    }

    public static void main(String[] args) {
        Problem929 prob = new Problem929();
        System.out.println(prob.numUniqueEmails(new String[]{
            "test.email+alex@leetcode.com",
            "test.e.mail+bob.cathy@leetcode.com",
            "testemail+david@lee.tcode.com"})
        ); // 2
    }
}

@@ -12,16 +12,65 @@
 tcode;%0A%0A
+import java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 /**%0A * h
@@ -214,347 +214,497 @@
     
-// TODO%0A        return 0
+Set%3CString%3E emailSet = new HashSet%3C%3E()
 ;%0A    
-%7D%0A%0A
     
-public static void main(String%5B%5D args) %7B%0A        Problem929 prob = new Problem929();%0A        System.out.println(prob.numUniqueEmails(new String%5B%5D%7B%0A            %22test.email+alex@leetcode.com%22,%0A            %22test.e.mail+bob.cathy@leetcode.com%22,%0A            %22testemail+david@lee.tcode.com%22%7D)%0A        ); // 2
+for (String email : emails) %7B%0A            String%5B%5D emailSplit = email.split(%22@%22);%0A            String localName = emailSplit%5B0%5D;%0A            String hostName = emailSplit%5B1%5D;%0A            localName = localName.replaceAll(%22%5C%5C.%22, %22%22);%0A            int index = localName.indexOf(%22+%22);%0A            if (index %3E= 0) %7B%0A                emailSet.add(localName.substring(0, index) + %22@%22 + hostName);%0A            %7D%0A        %7D%0A        return emailSet.size();
 %0A   

Solve problem 929