python 刷题:实现队列
2016-03-17 16:26
489 查看
牛客在线刷题,地址:
http://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?rp=1&ru=/ta/cracking-the-coding-interview
用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。
http://www.nowcoder.com/practice/54275ddae22f475981afa2244dd448c6?rp=1&ru=/ta/cracking-the-coding-interview
用两个栈来实现一个队列,完成队列的Push和Pop操作。 队列中的元素为int类型。
# -*- coding:utf-8 -*- class Solution: def __init__(self): self.stack = [] def push(self, node): # write code here self.stack.append(node) def pop(self): # return xx if self.stack != []: return self.stack.pop(0) else: return 0
相关文章推荐
- [leetcode] @python 114. Flatten Binary Tree to Linked List
- python 列表list 元组tuple 字典dict 集合set 介绍
- PIL学习笔记
- Python 日志向控制台和文件输出
- 几款python集成开发环境
- Python进程
- python 编码问题
- 对Python面向对象的理解
- Python (九) 协程以及数据库操作
- Python 解析配置模块之ConfigParser详解
- python 刷题:替换空格
- python 刷题:从尾到头打印链表
- 简单python 模拟登陆
- python 刷题:变态跳台阶
- python 刷题:跳台阶
- 机器学习实战笔记(四):Logist线性回归算法的Python实现
- python设置字体颜色
- python 刷题:二维数组中的查找
- Java之——运行Python脚本的几种方式
- 机器学习实战笔记(三):决策树算法的Python实现