VOOZH about

URL: https://www.geeksforgeeks.org/cpp/list-rbegin-and-rend-function-in-c-stl/

⇱ list rbegin() and rend() function in C++ STL - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

list rbegin() and rend() function in C++ STL

Last Updated : 26 Jun, 2023

list::rbegin() is an inbuilt function in C++ STL that returns a reverse iterator which points to the last element of the list.

Syntax:

list_name.rbegin()

Parameter: This function does not accept any parameters.

Return value: It returns a reverse iterator which points to the last element of the list.

Below program illustrates the above function: 


Output
The list in reverse order: 50 40 30 20 10

Time Complexity: O(n)
Auxiliary Space: O(1)

list::rend() is an inbuilt function in C++ STL that returns a reverse iterator which points to the position before the beginning of the list.

Syntax:

list_name.rend()

Parameter: The function does not accept any parameters.

Return value: It returns a reverse iterator which points to the position before the beginning of the list.

Below program illustrates the above function: 


Output
The list in reverse order: 50 40 30 20 10

Time Complexity: O(n)
Auxiliary Space: O(1)

Comment
Article Tags: