Create 225.cpp

pull/46/head
Kirigaya Kazuto 2018-06-22 11:49:19 +08:00 committed by GitHub
parent 675f0145ec
commit 68c35fb868
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 32 additions and 0 deletions

32
LeetCode-CN/225.cpp Normal file
View File

@ -0,0 +1,32 @@
#include <list>
class MyStack {
public:
/** Initialize your data structure here. */
MyStack() {
}
/** Push element x onto stack. */
void push(int x) {
lst.push_back(x);
}
/** Removes the element on top of the stack and returns that element. */
int pop() {
int t = lst.back();
lst.pop_back();
return t;
}
/** Get the top element. */
int top() {
return lst.back();
}
/** Returns whether the stack is empty. */
bool empty() {
return lst.empty();
}
private:
std::list<int> lst;
};