rbegin(): This is a build-in function in STL. This function returns a read-only
(constant) iterator that points to the last element in the set.
Note: Iteration is done in descending order according to the keys.
This is available in the below file.
File: stl_set.h
Parameters: No parameters are required for this function.
Syntax:
set<data_type>::const_reverse_iterator it = st.rbegin()
For Example:
st = {1,2,3,4}
st.rbegin() = > It points to 4.
Approach
C++
#include <bits/stdc++.h>using namespace std;int main(){set<int> st;st.insert({1, 4, 3, 2});set<int>::const_reverse_iterator it = st.rbegin();cout << *it << "\n";return 0;}
No comments:
Post a Comment