队列
princey2100
这个作者很懒,什么都没留下…
展开
-
Leetcode 225. 用队列实现栈 Implement Stack using Queues - Python
from collections import dequeclass MyStack: def __init__(self): self.queue_in = deque() self.queue_out = deque() def push(self, x: int) -> None: self.queue_in.append(x) def pop(self) -> int: if self..原创 2022-03-26 13:56:56 · 561 阅读 · 0 评论 -
Leetcode 232. 用栈实现队列 Implement Queue using Stacks - Python 用双栈实现队列
class MyQueue: def __init__(self): self.stack_in = [] self.stack_out = [] def push(self, x: int) -> None: self.stack_in.append(x) def pop(self) -> int: if self.empty(): return None .原创 2022-03-26 12:38:45 · 974 阅读 · 0 评论