How to Find the Minimum Element in a List in C++? Last Updated : 16 Apr, 2024 Comments Improve Suggest changes Like Article Like Report In C++, a list is a sequence container provided by the STL library that stores data in non-contiguous memory locations efficiently. In this article, we will learn how to find the minimum element in a list in C++. Example: Input: myList = {30, 10, 20, 50, 40};Output: The minimum element in the list is: 10Find the Minimum Element in a List in C++To find the minimum element in a std::list, we can use the std::min_element() function. This function takes iterators to the first and last of the range and returns an iterator pointing to the minimum element present in the list. Syntax to Find the Minimum Element in a List*min_element(first, last);Here, the first and last are iterators to the begin and end denoting the range of elements in the list. C++ Program to Find the Minimum Element in a ListThe below program demonstrates how we can use the std::min_element function to find the minimum element in a list in C++. C++ // C++ program to find the minimum element in a list #include <algorithm> #include <iostream> #include <list> using namespace std; int main() { // Initializing a list of integers list<int> myList = { 30, 10, 20, 50, 40 }; // Finding the minimum element int mini = *min_element(myList.begin(), myList.end()); // Printing the maximum element of the list cout << "The minimum element in the list is : " << mini << endl; return 0; } OutputThe minimum element in the list is : 10 Time Complexity: O(N), where N is the size of the list.Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article How to Find the Minimum Element in a List in C++? P pantharshx9d9 Follow Improve Article Tags : C++ Programs C++ STL cpp-list CPP Examples +1 More Practice Tags : CPPSTL Similar Reads How to Find the Maximum Element in a List in C++? In C++, a list is a sequence container provided by the STL library that represents a doubly linked list and allows us to store data in non-contiguous memory locations efficiently. In this article, we will learn how to find the maximum element in a list in C++. Example: Input: myList = {30, 20, 10, 5 2 min read How to Find the Minimum Element in a Deque in C++? In C++, a deque (double-ended queue) container is a dynamic array that allows insertions and deletions at both ends. In this article, we will learn how to find the minimum element in a deque in C++. Example: Input: myDeque = {10, 5, 8, 3, 12}; Output: Minimum Element in the Deque: 3Finding the Minim 2 min read How to Find Minimum Element in a Vector in C++? Given a vector of n elements, the task is to find the minimum element using C++.ExamplesInput: v = {2, 4, 1, 5, 3}Output: 1Explanation: 1 is the smallest element in the vectorInput: v = {12, 34, 5, 7}Output: 5Explanation: 5 is the smallest element in the vector.Following are the 6 different methods 4 min read How to Find the Median of All Elements in a List in C++? In C++, a list is a container that allows us to store data in non-contiguous memory locations. The median of a list is defined as the middle element when the list size is odd, and the average of the two middle elements when the list size is even. In this article, we will learn how to find the median 3 min read How to Find the Sum of All Elements in a List in C++ STL? In C++, a list is a sequence container provided by the STL library that represents a doubly linked list and allows to store data in non-contiguous memory locations. In this article, we will learn how to find the sum of all elements in a list in C++. Example: Input:myList = {10, 20, 30, 40, 50};Outpu 2 min read How to Find the Mode of All Elements in a List in C++? In C++, a list is a sequence container used to store data of similar type in non-contiguous memory locations. The mode of a list represents the element that occurs most frequently in the container. In this article, we will learn how to find the mode of a list in C++. Example: Input:myList = {1, 2, 3 2 min read How to Find the First Element in a Set in C++? In C++, a set is a container that stores unique elements following a specific order. In this article, we will learn how to find the first element in a set. Example: Input: mySet = {1, 2, 4, 3, 8, 4, 7, 8, 6, 4} Output: First Element = 1Find the First Element in a Set in C++To find the first element 1 min read How to Find the Minimum Key in a Map in C++? In C++, a map is an associative container that stores key-value pairs. In this article, we will learn how to find the minimum key in a map in C++. Example: Input: myMap= {{10,"apple"},{5,"banana"},{20,"cherry"}};Output:Minimum key: 5Find the Smallest Key in a Map in C++There is no direct method avai 2 min read Find Maximum and Minimum Element in a Set in C++ STL In C++, set stores the unique elements in sorted order so it is pretty straightforward to find the minimum and maximum values. In this article, we will learn different methods to find the minimum and maximum values in a set in C++.As the set is sorted, the most efficient way to find the minimum and 3 min read Like