当前位置:网站首页>根据入栈顺序判断出栈顺序是否合理
根据入栈顺序判断出栈顺序是否合理
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'))
边栏推荐
- Wechat applet development process (with mind map)
- [安洵杯 2019]不是文件上传
- 我国算力规模排名全球第二:计算正向智算跨越
- De debugging (set the main thread as hidden debugging to destroy the debugging Channel & debugger detection)
- Rust区块琏开发——签名加密与私钥公钥
- IronXL for . NET 2022.6
- Use of vscode software
- ClickPaaS低代码平台
- About authentication services (front and back, login, registration and exit, permission management)
- Nmap user manual learning records
猜你喜欢

10种寻址方式之间的区别

Use Firefox browser to quickly pick up Web image materials

3. Package the bottom navigation tabbar

What is test development? Why do so many companies hire test developers now?

This article takes you to understand the relationship between the past and present of Bi and the digital transformation of enterprises

JWT漏洞复现

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

How to solve the problem that easycvr changes the recording storage path and does not generate recording files?

ActiveReportsJS 3.1 VS ActiveReportsJS 3.0

How is the entered query SQL statement executed?
随机推荐
MindFusion. Virtual Keyboard for WPF
【web源码-代码审计方法】审计技巧及审计工具
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?
官宣!第三届云原生编程挑战赛正式启动!
灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
Quick start of UI component development of phantom engine [umg/slate]
On the day 25K joined Tencent, I cried
Test d'automatisation de l'interface utilisateur télécharger manuellement le pilote du navigateur à partir de maintenant
Clickhouse物化视图
[wp][入门]刷弱类型题目
汇编-入门
C language course setting: cinema ticket selling management system
Some enterprise interview questions of unity interview
CTF stegano practice stegano 9
Uni app common functions /api
Summary of scene design
Rome链分析
DFS and BFS concepts of trees and graphs
为什么百度、阿里这些大厂宁愿花25K招聘应届生,也不愿涨薪5K留住老员工?
laravel8 导出Excle文件