nikunjsoni

929

Jun 23rd, 2021
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.49 KB | None | 0 0
  1. class Solution {
  2. public:
  3.     int numUniqueEmails(vector<string>& emails) {
  4.         unordered_set<string> st;
  5.         for(string &email : emails) {
  6.             string cleanEmail;
  7.             for(char c : email) {
  8.                 if(c == '+' || c == '@') break;
  9.                 if(c == '.') continue;
  10.                 cleanEmail += c;
  11.             }
  12.             cleanEmail += email.substr(email.find('@'));
  13.             st.insert(cleanEmail);
  14.         }
  15.         return st.size();
  16.     }
  17. };
Advertisement
Add Comment
Please, Sign In to add comment