40
来源:互联网 发布:windows系统智能电视 编辑:程序博客网 时间:2024/04/28 11:08
2017.9.19
public class MyQueue { private Stack<Integer> stack1; private Stack<Integer> stack2; public MyQueue() { // do intialization if necessary stack1 = new Stack<Integer>(); stack2 = new Stack<Integer>(); } /* * @param element: An integer * @return: nothing */ public void push(int element) { // write your code here while(!stack2.isEmpty()){ stack1.push(stack2.pop()); } stack1.push(element); } /* * @return: An integer */ public int pop() { // write your code here while(!stack1.isEmpty()){ stack2.push(stack1.pop()); } int x = stack2.pop(); while(!stack2.isEmpty()){ stack1.push(stack2.pop()); } return x; } /* * @return: An integer */ public int top() { // write your code here while(!stack1.isEmpty()){ stack2.push(stack1.pop()); } int x = stack2.peek(); while(!stack2.isEmpty()){ stack1.push(stack2.pop()); } return x; }}
阅读全文
0 0
- 40
- 40
- 40
- 40
- 40
- 【程序40】
- 练习40
- QTreeWidgetItem--40
- 40前积财
- nyoj-40
- NYOj 40
- 40 JavaBean
- #job 40
- Bestcoder #40
- 三++40
- P124.40
- p124 40
- P122.40
- LINTCODE——数字组合,数字组合II
- Android Switch控件修改样式
- ajax异步上传图片代码案例
- matlab中unifrnd函数用法
- DIV水平垂直居中
- 40
- 华为机试(取近似值,合并表,提取不重复整数,字符个数统计)Java实现
- url-pattern编写形式:【/与/*的区别】
- leet code 006:ZigZag Conversion
- vue-cli 子组件向父组件传递参数,触发父组件方法
- 九度题目1440:Goldbach's Conjecture
- 安卓按键下常见滑动命令和滑动问题总结(改)
- Leetcode OJ 79 Word Search [Medium]
- JS实现单链表