当前位置:网站首页>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'))
边栏推荐
- [array]566 Reshape the matrix - simple
- The architect started to write a HelloWorld
- 10种寻址方式之间的区别
- The order of LDS links
- @The problem of cross database query invalidation caused by transactional annotation
- About the recent experience of writing questions
- 北京程序员的真实一天!!!!!
- English essential vocabulary 3400
- 请问一下我的请求是条件更新,但在buffer中就被拦截了,这种情况我只能每次去flush缓存么?
- A brief introduction to the behavior tree of unity AI
猜你喜欢

Containerd series - what is containerd?

Online sql to excel (xls/xlsx) tool
![[web source code code code audit method] audit skills and tools](/img/7c/2c26578da084b3cd15d8f252b0e132.png)
[web source code code code audit method] audit skills and tools

The new project Galaxy token just announced by coinlist is gal

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

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

JWT漏洞复现

An elegant program for Euclid‘s algorithm

我就一写代码的,王总整天和我谈格局...

“金九银十”是找工作的最佳时期吗?那倒未必
随机推荐
What is test development? Why do so many companies hire test developers now?
行为感知系统
Basic function learning 02
面试字节,过关斩将直接干到 3 面,结果找了个架构师来吊打我?
Wechat applet development process (with mind map)
UI自动化测试从此告别手动下载浏览器驱动
Nmap user manual learning records
Online sql to excel (xls/xlsx) tool
How to solve the problem that easycvr changes the recording storage path and does not generate recording files?
C language course setting: cinema ticket selling management system
[an Xun cup 2019] not file upload
Uni app change the default component style
On the day 25K joined Tencent, I cried
【web审计-源码泄露】获取源码方法,利用工具
灵魂三问:什么是接口测试,接口测试怎么玩,接口自动化测试怎么玩?
Rust blockchain development - signature encryption and private key public key
EasyCVR平台出现WebRTC协议视频播放不了是什么原因?
3. Package the bottom navigation tabbar
[数组]566. 重塑矩阵-简单
Differences among 10 addressing modes