C++ STL quiz II , Q10 - Pop() doubt

Given question-


Let us build a stack data structure with the help of inbuilt vector class.

class myStack
{
vector < int > stack;
public:
int top();
void pop();
void push(int x);
}
Imagine the vector as a stack. The element at last position of the vector will be treated as top of the stack and element at stack[0] will be treated as the bottom of the stack.

Choose the correct option :

  1. top() and pop() can be implemented to work in O(1) time complexity.

  2. top() and push() can be implemented to work in O(1) time complexity.

  3. either pop() or push() will work in O(N) and the other will work in O(1).

  4. All functions can be implemented to work in O(1) time complexity.


I don’t understand how pop() will be implemented using vectors?