LeetCode_Implement Stack using Queues
2015-09-11 14:17
441 查看
原题链接:https://leetcode.com/problems/implement-stack-using-queues/
思路:使用双端队deque列实现栈 class Stack { public: deque<int> que; // Push element x onto stack. void push(int x) { que.push_front(x); } // Removes the element on top of the stack. void pop() { que.pop_front(); } // Get the top element. int top() { if(!que.empty()) { int x = que.front(); return x; } } // Return whether the stack is empty. bool empty() { return que.empty(); } };
相关文章推荐
- 页面顺序载入UI 方法
- Long Term Time Series Prediction and Stock Value Prediction
- Java String,StringBuilder和StringBuffer的用法和区别
- easyui datagrid 前后台代码
- Bouguet极线校正的方法
- LeetCode_Implement Queue using Stacks
- UIlabel自适应高度和自动换行
- UI一揽子计划 15 (XML的解析方式 (SAX解析/ DOM解析) 、JSON 解析)
- UI一揽子计划 14 (拖控件 、)
- 出现这个错误CUICatalog: Invalid asset name supplied: , or invalid scale factor: 2.000000
- NUI四种提交数据方式
- IOS使用UIImageView显示gif动画的例子
- IOS使用UIImageView显示gif动画的例子
- android stuido 编译报 Duplicate files copied in APK META-INF/LICENSE.txt 问题
- iOS --- UIViewController中的loadView使用场景
- iOS KVC setValuesForKeysWithDictionary的使用
- UI线程和工作线程
- iOS KVC setValuesForKeysWithDictionary的使用
- 解决UICollectionView内容填充不满无法下拉的问题
- UiTableview的常用小知识汇集