DEV Community

Mujahida Joynab
Mujahida Joynab

Posted on

List Operation Functions

#include <bits/stdc++.h>
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    list<int> l = {10, 20, 40,40,40,40,40 ,100, 30,10000,20000,10000};
    list<int> l2 = {11, 12, 13};

    l.sort(); // Ascending Order
    l.sort(greater<int>()); // Descanding Order


    l.unique() ; // Works when list is sorted. Print Unique values
    l.remove(10);
    l.reverse() ; //Reverse the list
    for (int val : l)
    {
        cout << val << endl;
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)