当前位置:网站首页>根据入栈顺序判断出栈顺序是否合理
根据入栈顺序判断出栈顺序是否合理
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'))
边栏推荐
- Web components series (VII) -- life cycle of custom components
- JWT漏洞复现
- grandMA2 onPC 3.1.2.5的DMX参数摸索
- 一文带你了解BI的前世今身与企业数字化转型的关系
- 反絮凝剂-氨碘肽滴眼液
- [move pictures up, down, left and right through the keyboard in JS]
- 【软件逆向-基础知识】分析方法、汇编指令体系结构
- Containerd series - what is containerd?
- Clickhouse同步mysql(基于物化引擎)
- [understand series after reading] 6000 words teach you to realize interface automation from 0 to 1
猜你喜欢
Containerd series - detailed explanation of plugins
How to use jedis of redis
北京程序员的真实一天!!!!!
Redis source code analysis: redis cluster
A brief introduction to the behavior tree of unity AI
How is the entered query SQL statement executed?
[数组]566. 重塑矩阵-简单
线程基础知识
On the day 25K joined Tencent, I cried
[wp][introduction] brush weak type questions
随机推荐
[PHP features - variable coverage] improper use, improper configuration and code logic vulnerability of the function
Interview byte, pass the exam and directly work on three sides. As a result, I found an architect to hang me?
10种寻址方式之间的区别
Analysis of dagger2 principle
为什么百度、阿里这些大厂宁愿花25K招聘应届生,也不愿涨薪5K留住老员工?
[array]566 Reshape the matrix - simple
Resolved (sqlalchemy+pandas.read_sql) attributeerror: 'engine' object has no attribute 'execution_ options‘
PlasticSCM 企业版Crack
[charging station]_ Secular wisdom_ Philosophical wisdom _
Clickhouse同步mysql(基于物化引擎)
speed or tempo in classical music
Anti debugging (basic principles of debugger Design & NT NP and other anti debugging principles)
speed or tempo in classical music
Rust区块琏开发——签名加密与私钥公钥
JWT vulnerability recurrence
Rome链分析
Differences among 10 addressing modes
The order of LDS links
Nmap使用手册学习记录
[数组]566. 重塑矩阵-简单