From 805b9bd638ac8e11e1ba379f87ebb9b8323948d4 Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Mon, 9 May 2022 19:40:20 +0800 Subject: [PATCH] =?UTF-8?q?20.=20=E7=94=A8=E4=B8=A4=E4=B8=AA=E6=A0=88?= =?UTF-8?q?=E5=AE=9E=E7=8E=B0=E9=98=9F=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://www.acwing.com/problem/content/submission/code_detail/14064595/ --- AcWing/20/20.cpp | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 AcWing/20/20.cpp diff --git a/AcWing/20/20.cpp b/AcWing/20/20.cpp new file mode 100644 index 00000000..9858f775 --- /dev/null +++ b/AcWing/20/20.cpp @@ -0,0 +1,40 @@ +class MyQueue { +private: + queue q; +public: + /** Initialize your data structure here. */ + MyQueue() { + + } + + /** Push element x to the back of queue. */ + void push(int x) { + q.push(x); + } + + /** Removes the element from in front of queue and returns that element. */ + int pop() { + int ret = q.front(); + q.pop(); + return ret; + } + + /** Get the front element. */ + int peek() { + return q.front(); + } + + /** Returns whether the queue is empty. */ + bool empty() { + return q.empty(); + } +}; + +/** + * Your MyQueue object will be instantiated and called as such: + * MyQueue* obj = new MyQueue(); + * obj->push(x); + * int param_2 = obj->pop(); + * int param_3 = obj->peek(); + * bool param_4 = obj->empty(); + */