Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- int main()
- {
- // 1.>basics of C++
- // 2.>basics of for/while/do while loops
- // 3.>basics of implementation/ arrays etc
- // 4.>recursion
- // 5.>binary search
- // 6.>searching/sorting techniques
- //stl techniques(vectors,maps,pairs)
- //prefix sum (technique)
- // 7.>hashing
- // 8.>two pointers
- // 9.>stacks_queues
- //lot of practise through contests and questions
- // 10. > sets
- // 11. > multisets
- // 12. > questions
- // 13. > sliding window technique
- //questions of mixed variety of all the concepts studied till here
- // 14. > strings algorithms
- // 15. > greedy algorithms
- // 16. > bits manipulation
- set<int> s;
- s.insert(100); s.insert(1000);
- s.insert(20); s.insert(2);
- // cout << s.size() << endl;
- //iteration
- // for (auto it = s.begin(); it != s.end(); it++)
- // {
- // cout << *it << " " << endl;
- // }
- // cout << endl;
- for (auto i : s)
- {
- cout << i << " " << endl;
- }
- // cout << endl;
- // cout << *(s.begin()) << endl;
- //iteration and iterators and how to insert in set
- //how to find or check an element in the set
- int x; cin >> x;
- if (s.find(x) == s.end())
- {
- cout << "NOT FOUND" << endl;
- }
- else cout << "FOUND" << endl;
- //how to erase a element in the set
- s.erase(s.find(x));
- for (auto i : s)
- {
- cout << i << endl;
- }
- //////////////////////////////////////////////////////////////////////////////
- // multiset<ll> m1; //store in ascending order
- // m1.insert(10); m1.insert(20); m1.insert(1); m1.insert(10);
- // for (auto i : m1) cout << i << " "; cout << endl;
- // cout << m1.count(10) << endl;//frequency of 10
- // m1.erase(10);//erased all instances/occurences of 10
- // for (auto i : m1) cout << i << " "; cout << endl;
- // m1.insert(10); m1.insert(10);
- // for (auto i : m1) cout << i << " "; cout << endl;
- // m1.erase(m1.find(10));//erased only single instance of 10
- // for (auto i : m1) cout << i << " "; cout << endl;
- // auto it1 = m1.begin();
- // cout << *it1 << endl << endl << endl; //or*m1.begin()
- ///////////////////////////////////////////////////////////////////////////////////////
- multiset<ll, greater<ll>> m2; //store in descending order
- m2.insert(10); m2.insert(20); m2.insert(1); m2.insert(10);
- for (auto i : m2) cout << i << " "; cout << endl;
- cout << m2.count(10) << endl;//ferqeuency of 10
- m2.erase(10);//erased all instances of 10
- for (auto i : m2) cout << i << " "; cout << endl;
- m2.insert(10); m2.insert(10);
- for (auto i : m2) cout << i << " "; cout << endl;
- m2.erase(m2.find(10));//erased only single instance of 10
- for (auto i : m2) cout << i << " "; cout << endl;
- auto it2 = m2.begin();
- cout << *it2 << endl;//or*m2.begin()
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement