We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 410fb19 commit e5b80cbCopy full SHA for e5b80cb
unique-email-addresses/unique-email-addresses.cpp
@@ -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
21
+ unordered_set<string> st;
22
23
+ for(auto str: emails){
24
+ ss.clear();
25
26
27
+ string arr[2];
28
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