wangcy6 / leetcode

LeetCode Problems' Solutions
5 stars 1 forks source link

每日一题(2019-08-14):232. Implement Queue using Stacks #3

Closed watchpoints closed 5 years ago

watchpoints commented 5 years ago

https://leetcode.com/problems/implement-queue-using-stacks/ Implement the following operations of a queue using stacks.

push(x) -- Push element x to the back of queue. pop() -- Removes the element from in front of queue. peek() -- Get the front element. empty() -- Return whether the queue is empty. Example:

MyQueue queue = new MyQueue();

queue.push(1); queue.push(2);
queue.peek(); // returns 1 queue.pop(); // returns 1 queue.empty(); // returns false

watchpoints commented 5 years ago

https://mp.weixin.qq.com/s/oIjJjZf8LcJS8-qL0xZQQQ