当前位置:网站首页>Judge whether the stack order is reasonable according to the stack order
Judge whether the stack order is reasonable according to the stack order
2022-07-05 04:01:00 【Poetry and prodigal son】
def is_pop_order(push, pop):
""" Judge whether the stack order is reasonable according to the stack order :param push: Stack order :param pop: Out of stack order :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'))
边栏推荐
- 反絮凝剂-氨碘肽滴眼液
- EasyCVR更改录像存储路径,不生成录像文件如何解决?
- Why is there a reincarnation of 60 years instead of 120 years in the tiangan dizhi chronology
- 灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
- WGS84 coordinate system, web Mercator, gcj02 coordinate system, bd09 coordinate system - brief introduction to common coordinate systems
- ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
- 【无标题】
- [understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
- Phpmailer reported an error: SMTP error: failed to connect to server: (0)
- 一文带你了解BI的前世今身与企业数字化转型的关系
猜你喜欢

面试汇总:这是一份全面&详细的Android面试指南

NEW:Devart dotConnect ADO. NET

CTF stegano practice stegano 9

Clickhouse物化视图

MindFusion.Virtual Keyboard for WPF

Special Edition: spreadjs v15.1 vs spreadjs v15.0

KVM virtualization

面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?

线上故障突突突?如何紧急诊断、排查与恢复
![[C language] address book - dynamic and static implementation](/img/eb/07e7a32a172e5ae41457cf8a49c130.jpg)
[C language] address book - dynamic and static implementation
随机推荐
[software reverse - basic knowledge] analysis method, assembly instruction architecture
postman和postman interceptor的安装
Wechat applet development process (with mind map)
This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises
测试开发是什么?为什么现在那么多公司都要招聘测试开发?
[C language] address book - dynamic and static implementation
Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
Rust区块琏开发——签名加密与私钥公钥
ActiveReportsJS 3.1 VS ActiveReportsJS 3.0
面试汇总:这是一份全面&详细的Android面试指南
[web Audit - source code disclosure] obtain source code methods and use tools
Rome链分析
[web source code code code audit method] audit skills and tools
Basic function learning 02
一文带你了解BI的前世今身与企业数字化转型的关系
Get to know MySQL connection query for the first time
speed or tempo in classical music
Use threejs to create geometry and add materials, lights, shadows, animations, and axes
函数基础学习02
What is the reason why the webrtc protocol video cannot be played on the easycvr platform?