Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- int main () {
- ios::sync_with_stdio(false);
- cin.tie(nullptr);
- cout.tie(nullptr);
- vector<int> v;
- v.push_back(15); //insertion operation
- v.push_back(10);
- v.push_back(20);
- //~ cout << v.size() << '\n'; //size of vector
- //~ for (int i = 0; i < v.size(); i++) {
- //~ cout << v[i] << ' ';
- //~ }
- //v.begin(); //beginning point
- //v.end(); //ending point
- //~ cout << "BEFORE SORTING : \n";
- //~ for (int i = 0; i < v.size(); ++i) {
- //~ cout << v[i] << ' ';
- //~ }
- sort(v.begin(),v.end()); //accending order
- //~ cout << "\nAFTER SORTING : \n";
- //~ for (int i = 0; i < v.size(); ++i) {
- //~ cout << v[i] << ' ';
- //~ }
- //~ cout << "\nDECENDING ORDER\n";
- //~ sort (v.rbegin(),v.rend()); //decending order
- //~ for (int i = 0; i < v.size(); ++i) {
- //~ cout << v[i] << ' ';
- //~ }
- //binary_search(starting_point,ending_point,x); // 0(x nai) , 1(x ache)
- //~ int x = 11;
- //~ int f = binary_search(v.begin(),v.end(),x); //time complexity = log2(n)
- //~ cout << f << '\n';
- //~ if (f == 1) {
- //~ cout << "ACHE\n";
- //~ } else {
- //~ cout << "NAI\n";
- //~ }
- //upper_bound(starting_point,ending_point,x) //it will return imi greater value
- //lower_bound(starting_point,ending_point,x) //it will return x if x is present otherwise upper_bound
- //~ auto it = upper_bound(v.begin(),v.end(),20);
- //~ if (it == v.end()) {
- //~ cout << "YES\n";
- //~ }
- //10,15,20
- //~ auto it = lower_bound(v.begin(),v.end(),21);
- //~ if (it == v.end()) {
- //~ cout << "YES\n";
- //~ }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement