当前位置:网站首页>根据入栈顺序判断出栈顺序是否合理
根据入栈顺序判断出栈顺序是否合理
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'))
边栏推荐
- Deflocculant aminoiodotide eye drops
- 在线文本行固定长度填充工具
- 灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
- [untitled]
- Summary of scene design
- Some enterprise interview questions of unity interview
- Uni app common functions /api
- De debugging (set the main thread as hidden debugging to destroy the debugging Channel & debugger detection)
- ABP vNext microservice architecture detailed tutorial - distributed permission framework (Part 2)
- Excuse me, my request is a condition update, but it is blocked in the buffer. In this case, can I only flush the cache every time?
猜你喜欢

IronXL for .NET 2022.6

JWT漏洞复现

Laravel8 export excel file
![[vérification sur le Web - divulgation du code source] obtenir la méthode du code source et utiliser des outils](/img/ea/84e67a1fca0e12cc4452c744c242b4.png)
[vérification sur le Web - divulgation du code source] obtenir la méthode du code source et utiliser des outils
![[positioning in JS]](/img/f1/02ce74fadc1f7524c7abca9db66c71.jpg)
[positioning in JS]

This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises
![[web Audit - source code disclosure] obtain source code methods and use tools](/img/ea/84e67a1fca0e12cc4452c744c242b4.png)
[web Audit - source code disclosure] obtain source code methods and use tools

grandMA2 onPC 3.1.2.5的DMX参数摸索

KVM virtualization

Online sql to excel (xls/xlsx) tool
随机推荐
[move pictures up, down, left and right through the keyboard in JS]
As soon as I write the code, President Wang talks with me about the pattern all day
MindFusion. Virtual Keyboard for WPF
Deflocculant aminoiodotide eye drops
一文带你了解BI的前世今身与企业数字化转型的关系
Laravel8 export excel file
NEW:Devart dotConnect ADO. NET
How to make the listbox scroll automatically when adding a new item- How can I have a ListBox auto-scroll when a new item is added?
天干地支纪年法中为什么是60年一个轮回,而不是120年
NEW:Devart dotConnect ADO.NET
ClickPaaS低代码平台
Yuancosmic ecological panorama [2022 latest]
Clickhouse synchronization MySQL (based on materialization engine)
CTF stegano practice stegano 9
error Couldn‘t find a package. JSON file in "your path“
【web源码-代码审计方法】审计技巧及审计工具
输入的查询SQL语句,是如何执行的?
Is there a sudden failure on the line? How to make emergency diagnosis, troubleshooting and recovery
Assembly - getting started
What is the reason why the webrtc protocol video cannot be played on the easycvr platform?