Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Q
- // - add str
- // - pop str
- #include <iostream>
- #include <string>
- #include <unordered_set>
- /*
- add abcd // (4)
- add def // (4, 3)
- pop qwe //
- pop def
- pop abcd
- */
- int main() {
- std::unordered_set<std::string_view> words; // error, correct: std::string_view -> std::string
- std::string request;
- std::string word;
- while (std::cin >> request >> word) {
- if (request == "add") {
- words.insert(word);
- } else if (request == "pop") {
- std::unordered_set<std::string_view>::iterator it = words.find(word);
- if (it == words.end()) {
- std::cout << "NO\n";
- } else {
- std::cout << "YES\n";
- words.erase(it);
- }
- }
- }
- }
- std::set<int>::iterator it;
- ++it;
- --it;
- std::advance(it, 10);
- std::advance(it, -10);
- std::distance(it, myset.end());
- std::vector<int>::itearator it2;
- it2 += 3;
- it2 -= 4;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement