剑指offer 面试题7 两个栈实现队列
来源:互联网 发布:遥知兄弟登高处的翻译 编辑:程序博客网 时间:2024/04/29 07:26
template <typename T> class Queue{public:Queue();~Queue();T dequeue();void inqueue(const T& element);private:std::stack<T> st1;//for inqueuestd::stack<T> st2;//for dequeue};template <typename T> void inqueue(const T& element){st1.push(element);}template <typename T> T dequeue(){if(st2.size()<=0){while(st1.size()>0){T& element=st1.top();st1.pop();st2.push(element);}}if(st2.size()==0){throw exception("empty queue.");}T head=st2.top();st2.pop();return head;}
0 0
- 剑指offer-->面试题7 用两个栈实现队列
- 【剑指offer】面试题7:两个栈实现队列
- 【剑指offer】面试题7:用两个栈实现队列
- 剑指offer 面试题7 两个栈实现队列
- 剑指Offer:面试题7 用两个栈实现队列
- 剑指offer--面试题7两个栈实现队列
- 剑指offer 面试题7 两个栈实现队列
- 《剑指Offer》面试题7:用两个栈实现队列
- 【剑指offer】 面试题7: 用两个栈实现队列
- 【剑指offer】面试题7:用两个栈实现队列
- 剑指offer-面试题7:用两个栈实现队列
- 剑指offer---面试题7 用两个栈实现队列
- 剑指offer面试题7:用两个栈实现队列
- 剑指Offer面试题7用两个栈实现队列
- 【剑指offer】面试题7:用两个栈实现队列
- 剑指offer面试题7:用两个栈实现队列
- 剑指offer--面试题7: 用两个栈实现队列
- 剑指offer-面试题7-用两个栈实现队列
- 快速掌握一个语言最常用的50%
- Spring对事务配置的五种方式和事务的传播属性和隔离级别
- Spring定时器表达式
- oracle中lob类型
- C# LINQ to Objects
- 剑指offer 面试题7 两个栈实现队列
- 今天开始学java
- Creation of the private accessor ... failed in Visual Studio 2010
- PageObjects 设计模式
- JVM调优总结 + jstat 分析
- oracle对于大表利用rowid提升update性能
- Android数据存储实现的5大方式
- Myslqdump命令使用说明(学习笔记)超级详细
- linux ethernet PHY 驱动