两个栈实现一个队列
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
web_server
Tengine
TCP/UDP
Code
go-scrcpy-client
python
总结
爬虫
git
golang
段子
QR
梦中的婚礼
2019
spider
dateutil
go语言
快排
devices
RTL8821CU
Jetson
Wi-Fi
nginx
socket
排列组合
go
算法
递归
go_common
bash
adb
bilibili
rapsi
FastDfs
docker
Rust
RTL8811CU
数据结构
lua
raspi
遇见
USB
nano
stack
JAVA
shell
Timer
C
manager
contentext
同桌的你
Linux
排序
command
linux
risc64
Site statistics
正在加载今日诗词....
本站现有文章40篇,共被浏览127134次
本次响应耗时: 0.274s
当前来路IP: 216.73.216.123
您是本站第: 223872 位访客!
本站已苟活:
All hots
Article archiving