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