You are viewing a single comment's thread. Return to all comments →
Suggestion: Use std::multiset instead of std::vector. Then you don't need to do sort, like this(just gonna re-write your code a bit differently):
#include <set> #include <iostream> using namespace std; int main() { int N; cin >> N; regex e(".+@gmail\\.com$"); multiset<string> db; for(int a0 = 0; a0 < N; a0++) { string firstName; string emailID; cin >> firstName >> emailID; if(regex_match(emailID,e)) { db.insert(firstName); } } // just a fancy and less robust way of iterating in // C++11 (and later) for(auto& it : db) { cout << it << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Day 28: RegEx, Patterns, and Intro to Databases
You are viewing a single comment's thread. Return to all comments →
Suggestion: Use std::multiset instead of std::vector. Then you don't need to do sort, like this(just gonna re-write your code a bit differently):