![]() |
VOOZH | about |
In C++, deque also known as double-ended queues are containers that allow efficient insertion and deletion operations from both ends of the deque. In this article, we will learn how to find the size of a deque in C++.
Example:
Input: myDeque = {10, 20, 30, 40, 50} Output: Size of the Deque is: 5
In C++, the std::deque container keeps track of its size. We can simply use the std::deque::size()member function of the std::deque class to get the size of the deque container. It returns the size i.e., the number of elements present in the deque in the form of an integer.
dq_name.size()
The below program demonstrates how we can find the size of a deque in C++.
Size of the Deque is: 5
Time Complexity: O(1)
Auxiliary Space: O(1)