How to Find the Minimum Element in a Deque in C++? Last Updated : 27 Mar, 2024 Summarize Comments Improve Suggest changes Share Like Article Like Report 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 Minimum Element in a Deque in C++ To find the minimum element in a std::deque container, we can use the std::min_element() algorithm provided in STL that takes the iterator to the first and last of the range and returns the iterator to the minimum element in the range. Syntax to Use std::min_element()min_element (first, last);Here, first is the iterator pointing to the beginning of the range.last is the iterator pointing to the end of the range.C++ Program to Find the Minimum Element in a DequeThe below example demonstrates how we can find the minimum element in a deque in C++. C++ // C++ Program to demonstrates how we can find the minimum // element in a deque #include <algorithm> #include <deque> #include <iostream> using namespace std; int main() { // Creating a deque with some elements deque<int> myDeque = { 10, 5, 8, 3, 12 }; // Finding the minimum element using min_element // function auto res = min_element(myDeque.begin(), myDeque.end()); // Checking if min_element found a valid minimum element if (res != myDeque.end()) { cout << "Minimum Element in the Deque: " << *res << endl; } else { cout << "Deque is empty." << endl; } return 0; } OutputMinimum Element in the Deque: 3 Time Complexity: O(N), here N is the number of elements in the deque.Auxiliary Space: O(1) Comment More infoAdvertise with us Next Article How to Find the Maximum Element in a Deque in C++? G gauravgandal Follow Improve Article Tags : C++ Programs C++ STL cpp-deque CPP Examples +1 More Practice Tags : CPPSTL Similar Reads How to Find the Maximum Element in a Deque in C++? in C++, double-ended queues, also known as deques, are sequence containers with the feature of insertion and deletion on both ends. They are similar to vectors but are more efficient for the insertion and deletion of elements from both ends. In this article, we will learn how to find the maximum ele 2 min read How to Find the Minimum Element in a List in C++? 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 i 2 min read How to Find the Sum of All Elements in a Deque in C++? In C++, double-ended queues are sequence containers similar to vectors but are more efficient in the case of insertion and deletion of elements at both ends. In this article, we will learn how to find the sum of all elements in a deque in C++. Example Input: myDeque ={1,2,3,4,5} Output: Sum of all d 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 Median of All Elements in a Deque in C++? In C++, the median of the deque is defined as the middle element when the size of the deque is odd and the average of the middle two elements when the size is even in the sorted deque. In this article, we will learn how to find the median of all elements in a deque in C++. Example: Input:Deque = {3, 2 min read How to Find Mode of All Elements in a Deque in C++? In C++, deque is a container provided by the STL library of C++ that allows insertion and deletion from both ends. The mode of a deque represents the element that appears most frequently in the container. In this article, we will learn how to find the mode of all elements in a deque in C++. Example: 2 min read Like