当前位置:网站首页>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'))
边栏推荐
- Differences among 10 addressing modes
- Pyqt pyside custom telescopic menu bar sharing (including tutorial)
- ClickPaaS低代码平台
- provide/inject
- 天干地支纪年法中为什么是60年一个轮回,而不是120年
- Timing manager based on C #
- Threejs realizes rain, snow, overcast, sunny, flame
- Laravel8 export excel file
- Use Firefox browser to quickly pick up Web image materials
- Rust blockchain development - signature encryption and private key public key
猜你喜欢
JVM garbage collection
Clickhouse同步mysql(基于物化引擎)
线上故障突突突?如何紧急诊断、排查与恢复
IronXL for . NET 2022.6
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
[software reverse - basic knowledge] analysis method, assembly instruction architecture
This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises
面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?
As soon as I write the code, President Wang talks with me about the pattern all day
[array]566 Reshape the matrix - simple
随机推荐
speed or tempo in classical music
KVM virtualization
Why can't all browsers on my computer open web pages
UE4 DMX和grandMA2 onPC 3.1.2.5的操作流程
MindFusion. Virtual Keyboard for WPF
【看完就懂系列】一文6000字教你从0到1实现接口自动化
Assembly - getting started
IronXL for . NET 2022.6
测试开发是什么?为什么现在那么多公司都要招聘测试开发?
Uni app common functions /api
JWT漏洞复现
Soul 3: what is interface testing, how to play interface testing, and how to play interface automation testing?
【PHP特性-变量覆盖】函数的使用不当、配置不当、代码逻辑漏洞
open graph协议
Get to know MySQL connection query for the first time
An elegant program for Euclid‘s algorithm
一文带你了解BI的前世今身与企业数字化转型的关系
Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
JWT vulnerability recurrence
在线SQL转Excel(xls/xlsx)工具