Clean Java Beats 99+% Single Pass Without Split, Replace, or IndexOf
it seems best to just iterate once through each email string, since using String split() or replace() or indexOf() implicitly iterates through the email string 
it seems best to just iterate once through each email string, since using String split() or replace() or indexOf() implicitly iterates through the email string at each usage.\nAt each character:\n1. If \'.\' is encountered: skip to check next character\n2. If \'+\' is encountered: keep moving index to look for \'@\', then append rest of substring to StringBuilder; break\n3. If \'@\' is encountered: append rest of substring to StringBuilder; break\n4. For all other characters encountered, append to StringBuilder, then continue to check next character\n5. Build email string and add to set\n\nThe set size is result.\n```\n    public int numUniqueEmails(String[] emails) {\n      if (emails == null) {\n        return 0;\n      }\n\n      Set<String> addresses = new HashSet<>();\n\t  \n      for (String email : emails) {\n        StringBuilder sb = new StringBuilder();\n        for (int i = 0; i < email.length(); i++) {\n          char ch = email.charAt(i);\n          switch (ch) {\n            case \'.\':\n              break;\n            case \'+\':\n              while (ch != \'@\') {\n                ch = email.charAt(++i);\n              }\n              sb.append(email.substring(i));\n              i = email.length();\n              break;\n            case \'@\':\n              sb.append(email.substring(i));\n              i = email.length();\n            default:\n              sb.append(ch);\n          }\n        }\n        addresses.add(sb.toString());\n      }\n     \n      return addresses.size();\n    }\n```
[]