STL in C++
is_sorted()
: used to check whether the element of the given range is sorted or not in ascending order.
1
2
3
4
vector<int> v = {1, 2, 3, 4, 5};
if (is_sorted(v.begin(), v.end())) cout << "Sorted";
else cout << "Not Sorted";
find()
: used to check whether a substring exists in a string.
1
2
3
4
5
string str = "..#...#..#.";
string x = "...";
if (str.find(x) != -1) cout << "Found";
else cout << "Not Found";
This post is licensed under CC BY 4.0 by the author.