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();
}
}
标签:Addresses,idx,int,substring,929,idx1,Unique,local,String 来源: https://www.cnblogs.com/exhausttolive/p/10630279.html