美文网首页 剑指offer
2019-06-22-用两个栈实现队列

2019-06-22-用两个栈实现队列

作者: 兰为鹏 | 来源:发表于2019-06-22 11:35 被阅读0次

    题目描述
    用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。
    去刷题

    let stack1 = [];
    function push(node)
    {
        // write code here
        stack1.push(node)
    }
    function pop()
    {
        // write code here
        return stack1.shift();
    }
    module.exports = {
        push : push,
        pop : pop
    };
    

    相关文章

      网友评论

        本文标题:2019-06-22-用两个栈实现队列

        本文链接:https://www.haomeiwen.com/subject/mammqctx.html