当前位置:网站首页>根据入栈顺序判断出栈顺序是否合理
根据入栈顺序判断出栈顺序是否合理
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'))
边栏推荐
- 深度学习——LSTM基础
- 【web审计-源码泄露】获取源码方法,利用工具
- 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?
- laravel8 导出Excle文件
- Nmap user manual learning records
- EasyCVR更改录像存储路径,不生成录像文件如何解决?
- How does the applet solve the rendering layer network layer error?
- Alibaba cloud ECS uses cloudfs4oss to mount OSS
- How to use jedis of redis
- Deep learning - LSTM Foundation
猜你喜欢
阿里云ECS使用cloudfs4oss挂载OSS
C语言课设:影院售票管理系统
Installation of postman and postman interceptor
postman和postman interceptor的安装
【web審計-源碼泄露】獲取源碼方法,利用工具
UI自动化测试从此告别手动下载浏览器驱动
测试开发是什么?为什么现在那么多公司都要招聘测试开发?
Clickhouse synchronization MySQL (based on materialization engine)
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
Alibaba cloud ECS uses cloudfs4oss to mount OSS
随机推荐
[software reverse - basic knowledge] analysis method, assembly instruction architecture
[array]566 Reshape the matrix - simple
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?
[software reverse analysis tool] disassembly and decompilation tool
PlasticSCM 企业版Crack
线上故障突突突?如何紧急诊断、排查与恢复
Use Firefox browser to quickly pick up Web image materials
北京程序员的真实一天!!!!!
Phpmailer reported an error: SMTP error: failed to connect to server: (0)
An elegant program for Euclid‘s algorithm
On the day 25K joined Tencent, I cried
我国算力规模排名全球第二:计算正向智算跨越
Use object composition in preference to class inheritance
How to use jedis of redis
[vérification sur le Web - divulgation du code source] obtenir la méthode du code source et utiliser des outils
Clickpaas low code platform
Quick start of UI component development of phantom engine [umg/slate]
官宣!第三届云原生编程挑战赛正式启动!
UI automation test farewell to manual download of browser driver
Rome链分析