两个栈实现一个队列
class Solution(object):
"""
两个栈实现一个队列
"""
def __init__(self):
# -----
self.stack1 = []
self.stack2 = []
def push(self, element):
self.stack1.append(element)
def pop(self):
if self.stack2 == [] and self.stack1 == []:
raise IndexError("index out of range, stack is empty now!")
for val in range(len(self.stack1)):
self.stack2.append(self.stack1.pop(0))
return self.stack2.pop(0)
life is a boat
2
2
Author:Sato Please give credit to the original author when you use it elsewhere:https://www.mongona.com/blog/10
Category
Tags
遇见
dateutil
git
nano
rapsi
command
排序
Timer
golang
RTL8821CU
Rust
go-scrcpy-client
TCP/UDP
C
Jetson
Linux
spider
2019
nginx
risc64
django
python
manager
stack
数据结构
Wi-Fi
go语言
lua
RTL8811CU
同桌的你
JAVA
运维
web_server
段子
QR
shell
devices
USB
linux
go_common
socket
算法
adb
梦中的婚礼
contentext
递归
Tengine
FastDfs
Code
排列组合
总结
raspi
bash
docker
go
爬虫
bilibili
快排
Site statistics
正在加载今日诗词....
本站现有文章41篇,共被浏览95806次
本次响应耗时: 0.200s
当前来路IP: 35.171.159.141 unkonwn
您是本站第: 52209 位访客!
本站已苟活:
All hots
Article archiving