Leetcode Link: 225. 用队列实现栈 - 力扣(LeetCode)

题目

解法一

思路: 用list实现的

题解

class MyStack:
 
    def __init__(self):
        self.stack = []
 
    def push(self, x: int) -> None:
        self.stack.append(x)
 
    def pop(self) -> int:
        return self.stack.pop()
 
    def top(self) -> int:
        return self.stack[-1]
 
    def empty(self) -> bool:
        return True if len(self.stack)==0 else False