how to check if vector is ordered c 2b 2b

Solutions on MaxInterview for how to check if vector is ordered c 2b 2b by the best coders in the world

showing results for - "how to check if vector is ordered c 2b 2b"
Mathilda
04 Nov 2018
1#include <vector> // vector 
2#include <algorithm> // is_sorted
3#include <iostream> // cout 
4using namespace std;
5int main()
6{
7    vector<int> a = {6,5,3,5,7,8,5,2,1};
8    vector<int> b = {1,2,3,4,5,6,7,8,9};
9    
10    if(is_sorted(a.begin(), a.end()))
11        cout << "a is sorted\n";
12    else
13        cout << "a is not sorted\n";
14    
15    if(is_sorted(b.begin(), b.end()))
16        cout << "b is sorted\n";
17    else
18        cout << "b is not sorted\n";
19}