Skip to content

Commit e5b80cb

Browse files
committed
Time: 44 ms (15.52%), Space: 25.9 MB (5.94%) - LeetHub
1 parent 410fb19 commit e5b80cb

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
class Solution {
2+
public:
3+
string sanitise(string& str){
4+
stringstream ss;
5+
ss << str;
6+
7+
string token;
8+
while(getline(ss, token, '+')){
9+
break;
10+
}
11+
12+
string ans = "";
13+
for(auto x: token)
14+
if(x != '.')
15+
ans += x;
16+
17+
return ans;
18+
}
19+
int numUniqueEmails(vector<string>& emails) {
20+
stringstream ss;
21+
unordered_set<string> st;
22+
23+
for(auto str: emails){
24+
ss.clear();
25+
ss << str;
26+
27+
string arr[2];
28+
string token;
29+
30+
int i = 0;
31+
while(getline(ss, token, '@')){
32+
arr[i++] = token;
33+
}
34+
35+
string local = sanitise(arr[0]);
36+
string domain = arr[1];
37+
38+
cout << local + domain << endl;
39+
st.insert(local + "@" + domain);
40+
}
41+
42+
return (int)st.size();
43+
}
44+
};

0 commit comments

Comments
 (0)