deque Question 8

Last Updated :
Discuss
Comments

What will be the output of the following C++ code?

C++
#include <bits/stdc++.h>
using namespace std;
int main()
{
    deque<int> dq = {1, 2, 3};
    dq.push_back(4);
    dq.push_front(0);
    dq.pop_back();
    dq.pop_front();
    for (int i : dq)
        cout << i << " ";
    return 0;
}


0 1 2

2

1 2 3

1 2

Share your thoughts in the comments