Why my code is AC. someone can help me?


  • 0
    J
    class Stack(object):
    def __init__(self):
        """
        initialize your data structure here.
        """
        self.queue=collections.deque()
    
    def push(self, x):
        """
        :type x: int
        :rtype: nothing
        """
        if x:
            self.queue.append(x)
    def pop(self):
        """
        :rtype: nothing
        """
        return self.queue.pop()
    
    def top(self):
        """
        :rtype: int
        """
        return self.queue[-1]
    
    def empty(self):
        """
        :rtype: bool
        """
        return len(self.queue)==0

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.