剑指offer-两个栈模拟队列
来源:互联网 发布:tp框架源码 编辑:程序博客网 时间:2024/06/06 09:49
java的逻辑很简单:
- 两个栈模拟队列:
import java.util.Stack;public class Solution { Stack<Integer> stack1 = new Stack<Integer>(); Stack<Integer> stack2 = new Stack<Integer>(); public void push(int node) { stack1.push(node); } public int pop() { if(stack2.isEmpty()){ while(!stack1.isEmpty()){ stack2.push(stack1.pop()); } } if(stack2.isEmpty()){ return 0; } return stack2.pop(); }}
0 0
- 剑指offer-两个栈模拟队列
- 剑指offer之两个栈模拟队列操作
- 剑指Offer-- 两个栈模拟队列 替换空格
- [剑指offer]用两个栈实现队列
- 【剑指offer】两个栈实现一个队列
- 【剑指offer】两个队列实现一个栈
- 【剑指offer】用两个栈实现队列
- 剑指offer--用两个栈实现队列
- 剑指offer--两个栈生成队列
- 剑指offer 两个栈实现队列
- 剑指Offer-用两个栈实现队列
- 剑指offer:用两个栈实现队列
- 《剑指offer》用两个栈实现队列
- 用两个栈实现队列(剑指offer)
- 剑指 offer:用两个栈实现队列
- 【剑指Offer】用两个栈实现队列
- 剑指offer-用两个栈实现队列
- 《剑指offer》-用两个栈实现队列
- Hadoop经典案例Spark实现(二)——数据去重问题
- 2016注定是不平凡的一年
- java类反射
- 石头学PHP(一):Windows下的PHP7环境搭建
- svn管理 .so .a 文件
- 剑指offer-两个栈模拟队列
- 外部排序思想
- SpringMvc 学习笔记-------springmvc框架
- 深入解读泛型
- PhpStorm中terminal窗口字体修改
- 我的MYSQL学习心得(四) 数据类型
- 【最强眼力山寨版】钛合金眼神的试炼
- css定位在屏幕固定位置
- 文本挖掘的概述