You are viewing a single comment's thread. Return to all comments →
Thanks to C++'s STL, there're only 2 lines of code.
int main(){ int n; cin >> n; set<string> contacts; for(int a0 = 0; a0 < n; a0++){ string op; string contact; cin >> op >> contact; if (op == "add") contacts.insert(contact); else cout << distance(contacts.lower_bound(contact), contacts.upper_bound(contact + char('z' +1))) << endl; } return 0; }
Seems like cookies are disabled on this browser, please enable them to open this website
Tries: Contacts
You are viewing a single comment's thread. Return to all comments →
Thanks to C++'s STL, there're only 2 lines of code.