blob: 61e2c889269a02b3bc60efe9062e5239d1ab9ef5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
#include "leetcode.h"
class MyStack {
public:
queue<int> q;
MyStack() {}
void push(int x) {
int n = q.size();
q.push(x);
while (n--) {
q.push(q.front());
q.pop();
}
}
int pop() {
int ans = top();
q.pop();
return ans;
}
int top() { return q.front(); }
bool empty() { return q.empty(); }
};
int main() {}
|