剑指offer
用两个栈实现队列
相似的企业真题
时间限制:C/C++ 1秒,其他语言2秒
空间限制:C/C++ 64M,其他语言128M
热度指数:775955
本题知识点:
栈
算法知识视频讲解
校招时部分企业笔试将禁止编程题跳出页面,为提前适应,练习时请使用在线自测,而非本地IDE。
题目描述
用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。
上一题
下一题
登录
/
注册
我的提交
编辑器加载中...
import java.util.Stack; public class Solution { Stack
stack1 = new Stack
(); Stack
stack2 = new Stack
(); public void push(int node) { } public int pop() { } }
class Solution { public: void push(int node) { } int pop() { } private: stack
stack1; stack
stack2; };
# -*- coding:utf-8 -*- class Solution: def push(self, node): # write code here def pop(self): # return xx
class Solution { public void push(int node) { } public int pop() { } }
function push(node) { // write code here } function pop() { // write code here } module.exports = { push : push, pop : pop };
function push(node) { // write code here } function pop() { // write code here }
# -*- coding:utf-8 -*- class Solution: def push(self, node): # write code here def pop(self): # return xx
package main var stack1 [] int var stack2 [] int func Push(node int) { } func Pop() int{ }