Skip to content

Latest commit

 

History

History
53 lines (35 loc) · 765 Bytes

225._implement_stack_using_queues.md

File metadata and controls

53 lines (35 loc) · 765 Bytes

###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 == []