//url:https://leetcode.com/problems/unique-email-addresses/
第一次用golang写,感觉好不喜欢,这个的效率很低
solution 1:
func numUniqueEmails(emails []string) int {
dict := map[string]string{}
for _, value := range emails {
ignore := false
meetFlag:=false
tmp := ""
for sIndex, sValue := range value {
switch sValue {
case '@':
{
tmp += string(value[sIndex])
ignore = false
meetFlag=true
}
case '.':
{
if meetFlag {
tmp += string(value[sIndex])
}else{
continue
}
}
case '+':
{
ignore = true
}
default:
{
if ignore {
continue
} else {
tmp += string(value[sIndex])
}
}
}
}
dict[tmp] = tmp
}
return len(dict)
}