当前位置:网站首页>根据入栈顺序判断出栈顺序是否合理
根据入栈顺序判断出栈顺序是否合理
2022-07-05 04:00:00 【诗与浪子】
def is_pop_order(push, pop):
""" 根据入栈顺序判断出栈顺序是否合理 :param push: 入栈顺序 :param pop: 出栈顺序 :return: """
if len(push) == 0:
return False
stack = []
j = 0
for i in range(len(push)):
stack.append(push[i])
while j < len(pop) and stack and stack[-1] == pop[j]:
stack.pop()
j += 1
if len(stack) == 0:
return True
else:
return False
print(is_pop_order('1234', '4321'))
print(is_pop_order('1234', '1423'))
print(is_pop_order('1234', '2134'))
边栏推荐
- [charging station]_ Secular wisdom_ Philosophical wisdom _
- How is the entered query SQL statement executed?
- 函数基础学习02
- [punch in questions] integrated daily 5-question sharing (phase III)
- Rome链分析
- “金九银十”是找工作的最佳时期吗?那倒未必
- Special Edition: spreadjs v15.1 vs spreadjs v15.0
- How to use jedis of redis
- Pyqt pyside custom telescopic menu bar sharing (including tutorial)
- 反絮凝剂-氨碘肽滴眼液
猜你喜欢

Online text line fixed length fill tool
![[C language] address book - dynamic and static implementation](/img/eb/07e7a32a172e5ae41457cf8a49c130.jpg)
[C language] address book - dynamic and static implementation

输入的查询SQL语句,是如何执行的?

EasyCVR平台出现WebRTC协议视频播放不了是什么原因?

error Couldn‘t find a package.json file in “你的路径“

Redis source code analysis: redis cluster

【web源码-代码审计方法】审计技巧及审计工具

UE4 DMX和grandMA2 onPC 3.1.2.5的操作流程

About the recent experience of writing questions

JWT漏洞复现
随机推荐
An elegant program for Euclid‘s algorithm
What is test development? Why do so many companies hire test developers now?
laravel8 导出Excle文件
阿里云ECS使用cloudfs4oss挂载OSS
Use Firefox browser to quickly pick up Web image materials
Analysis of glibc strlen implementation mode
[positioning in JS]
[move pictures up, down, left and right through the keyboard in JS]
Web components series (VII) -- life cycle of custom components
深度学习——LSTM基础
Phpmailer reported an error: SMTP error: failed to connect to server: (0)
C语言课设:影院售票管理系统
IronXL for . NET 2022.6
JWT漏洞复现
EasyCVR更改录像存储路径,不生成录像文件如何解决?
lds链接的 顺序问题
grandMA2 onPC 3.1.2.5的DMX参数摸索
汇编-入门
已解决(sqlalchemy+pandas.read_sql)AttributeError: ‘Engine‘ object has no attribute ‘execution_options‘
Timing manager based on C #