stack 模拟 queue
来源:互联网 发布:alias软件安装 编辑:程序博客网 时间:2024/06/05 19:03
class Queue {public: stack<int>A; stack<int>B; // Push element x to the back of queue. void push(int x) { A.push(x); } // Removes the element from in front of queue. void pop(void) { while(B.size()){ B.pop(); } while(A.size()){ B.push(A.top()); A.pop(); } B.pop(); while(B.size()){ A.push(B.top()); B.pop(); } } // Get the front element. int peek(void) { while(B.size()){ B.pop(); } while(A.size()){ B.push(A.top()); A.pop(); } int t=B.top(); while(B.size()){ A.push(B.top()); B.pop(); } return t; } // Return whether the queue is empty. bool empty(void) { return A.size()==0; }};
0 0
- stack 模拟 queue
- queue 模拟 stack
- 模拟实现 stack和queue
- 模板模拟实现stack和queue
- 【数据结构】Stack和Queue的模拟实现
- 模拟实现容器适配器 stack queue
- stack,queue
- Queue\Stack
- queue stack
- Stack&Queue
- stack&queue
- stack/queue
- Stack && Queue
- ZOJ 3210 A Stack or A Queue?【模拟】
- STL库中的stack和queue及其模拟实现
- LeetCode[Stack]----Min Stack&Stack&Queue
- Java - Queue Stack
- Queue和Stack
- 1-1-4 链接器脚本
- jquery动态生成html代码 怎么 获取id 或 class
- csu 1106 最优对称路径(最短路+记忆化搜索)
- A query was run and no Result Maps were found
- 1-1-5 安装集成开发环境Eclipse
- stack 模拟 queue
- Spring Boot 集成Shiro和CAS
- <a>标签中使用js函数
- Git常用命令
- 最小生成树算法——prim,Kruskal
- Jmeter性能测试之如何写Java请求测试用例类
- 蓝鸥Unity开发基础—— 实践课程控制台玩家Demo
- Java服务器端微信支付V3版本功能实现
- 1-2 ARM概况