jjzjj

leetcode 232. Implement Queue using Stacks 用栈实现队列(简单)

一、题目大意标签:栈和队列https://leetcode.cn/problems/implement-queue-using-stacks请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(push、pop、peek、empty):实现MyQueue类:voidpush(intx)将元素x推到队列的末尾intpop()从队列的开头移除并返回元素intpeek()返回队列开头的元素booleanempty()如果队列为空,返回true;否则,返回false说明:你只能使用标准的栈操作——也就是只有 pushtotop, peek/popfromtop, size,和 isem

leetcode 232. Implement Queue using Stacks 用栈实现队列(简单)

一、题目大意标签:栈和队列https://leetcode.cn/problems/implement-queue-using-stacks请你仅使用两个栈实现先入先出队列。队列应当支持一般队列支持的所有操作(push、pop、peek、empty):实现MyQueue类:voidpush(intx)将元素x推到队列的末尾intpop()从队列的开头移除并返回元素intpeek()返回队列开头的元素booleanempty()如果队列为空,返回true;否则,返回false说明:你只能使用标准的栈操作——也就是只有 pushtotop, peek/popfromtop, size,和 isem