当前位置:网站首页>Sword finger offer (52): regularization expression
Sword finger offer (52): regularization expression
2022-07-26 10:46:00 【Konstanch】
Too many considerations , I don't understand yet , Put the code on first !
class Solution:
# s, pattern All strings
def match(self, s, pattern):
# write code here
if len(s) == 0 and len(pattern) == 0:
return True
elif len(s) != 0 and len(pattern) == 0:
return False
elif len(s) == 0 and len(pattern) != 0:
if len(pattern) > 1 and pattern != 0:
return self.match(s,pattern[2:])
else:
return False
else:
if len(pattern) > 1 and pattern[1] == '*':
if s[0] != pattern[0] and pattern[0] != '.':
return self.match(s,pattern[2:])
else:
return self.match(s,pattern[2:]) or self.match(s[1:],pattern[2:]) or self.match(s[1:],pattern)
else:
if s[0] == pattern[0] or pattern[0] == '.':
return self.match(s[1:],pattern[1:])
else:
return False
边栏推荐
猜你喜欢

Codepoint 58880 not found in font, aborting. flutter build apk时报错

PLC与伺服电机连接

在神州IV开发板上成功移植STemWin V5.22

Issue 8: cloud native -- how should college students learn in the workplace

IAR sprintf 浮点 在UCOS 总格式化成0.0的问题

Sql Server 数据库之数据类型

从蚂蚁的觅食过程看团队研发(转载)

Analysis of the transaction problem of chained method call

Issue 6: which mainstream programming language should college students choose

解决:无法加载文件 C:\Users\user\AppData\Roaming\npm\npx.ps1,因为在此系统上禁止运行脚本 。
随机推荐
MFC图片控件
Add touch screen driver for stemwin 5.22 on Shenzhou IV development board
Minesweeping Pro version 2021-08-19
Flutter报错 Incorrect use of ParentDataWidget When the exception was thrown, this was the stack:
Disable usbjatg in Altium Designer
二叉树的遍历 递归+迭代
algorithm
2021-08-14 Sanzi chess
Pengge C language sixth class
[leetcode daily question 2021/2/13]448. Find all the missing numbers in the array
工厂模式详解
为什么需要自动化测试?软件测试师带你测评不同软件测试工具
Sql Server 数据库之数据类型
[machine learning notes] [style transfer] deeplearning ai course4 4th week programming(tensorflow2)
Common classes (understand)
Build ARM embedded development environment
使用float实现左中右布局,中间内容自适应
剑指Offer(四十三):左旋转字符串
使用grid实现左中右布局,中间内容自适应
$router和$route的区别