![]() |
VOOZH | about |
In C++, a deque is a container provided by the STL library that is similar to a queue. However, unlike queues, it allows insertion and deletion from both ends. In this article, we will learn how to determine whether a deque is empty or not in C++.
Example:
Input: myDeque = {2, 4, 6 } Output: dq1 is not Empty.
To check if a std::deque is empty or not in C++, we can use the std::deque::empty() member function which returns a boolean value true if the deque is empty and false if the deque is not empty.
dq_name.empty()The below program demonstrates how we can check if a deque is empty or not in C++.
Deque is not empty After Removal: Deque is empty
Time Complexity: O(1)
Auxiliary Space: O(1)