#-*- coding: UTF-8 -*-
#双栈法
class Queue(object):
    def __init__(self):
        """
        initialize your data structure here.
        """
        self.inStack=[]
        self.outStack=[]
        

    def push(self, x):
        """
        :type x: int
        :rtype: nothing
        """
        self.inStack.append(x)
        

    def pop(self):
        """
        :rtype: nothing
        """
        self.peek()
        self.outStack.pop()
        

    def peek(self):
        """
        :rtype: int
        """
        if not self.outStack:
            while self.inStack:
                self.outStack.append(self.inStack.pop())
        return self.outStack[-1]
        

    def empty(self):
        """
        :rtype: bool
        """
        return True if (len(self.inStack)+len(self.outStack))==0 else False

最新文章

  1. 剖析并利用Visual Studio Code在Mac上编译、调试c#程序
  2. ibatis 和 mybatis
  3. c语言 如何判断是不是 可显字符
  4. Invoke-Express 执行多个批处理命令的函数
  5. HDU 5044 TREE
  6. 主流的phpcms分析
  7. Tomcat下work文件夹的作用
  8. [BZOJ 1026] [SCOI 2009] Windy数 【数位DP】
  9. tmux centos 6.3
  10. C语言_数字排列顺序
  11. 【Alpha】第七次Daily Scrum Meeting
  12. NHibernate3剖析:Configuration篇之SessionFactory lambda配置
  13. 如何使用Git提高研发团队工作效率?
  14. Weex小笔记(自己理解,有错请指正)
  15. UART中的硬件流控RTS与CTS DTR DSR DTE设备和DCE设备【转】
  16. 莫队算法 [国家集训队]小Z的袜子
  17. AngularJS实战之filter的使用二
  18. Windows网络命令
  19. 在weblogic上配置数据源
  20. winform 中 MessageBox 用法大全

热门文章

  1. cometd使用-bayeux协议(读法:贝叶)
  2. 《OpenGL着色语言》理解点记录三
  3. How to change Jenkins default folder on Windows?
  4. MapReduce之Mapper类,Reducer类中的函数(转载)
  5. spring的定时任务
  6. JSP页面跳转方式
  7. oracle 定时备份
  8. Hive文件格式
  9. git 本地分支与远程分支关联的一种方法
  10. Android Studio解决unspecified on project app resolves to an APK archive which is not supported