1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
class Stack {
public:
vector<int> stack;
// Push element x onto stack.
void push(int x) {
stack.push_back(x);
}
// Removes the element on top of the stack.
void pop() {
stack.pop_back();
}
// Get the top element.
int top() {
return stack[stack.size() - 1];
}
// Return whether the stack is empty.
bool empty() {
return stack.empty();
}
};
|