Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 820 Bytes

File metadata and controls

53 lines (35 loc) · 820 Bytes

225. 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 == []