225. Implement Stack using Queues

225. Implement Stack using Queues

题目:

https://leetcode.com/problems/implement-stack-using-queues/

难度:

Easy

又到了作弊神预言Python的强项

class Stack(object):
    def __init__(self):
        """
        initialize your data structure here.
        """
        self.lst = []
        

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

    def pop(self):
        """
        :rtype: nothing
        """
        self.lst.remove(self.lst[-1])
        

    def top(self):
        """
        :rtype: int
        """
        return self.lst[-1]

    def empty(self):
        """
        :rtype: bool
        """
        return self.lst == []
        
    原文作者:oo上海
    原文地址: https://www.jianshu.com/p/aac3c75b4db0
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞