当前位置:网站首页>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
边栏推荐
猜你喜欢

mysql20210906

Issue 5: the second essential skill for College Students

使用Selenium抓取zabbix性能监控图

在altium designer中禁用USBJATG

sigmod 函数与softmax 函数对比

Sql Server 数据库之数据类型

Analysis of the transaction problem of chained method call

Disable usbjatg in Altium Designer

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

Zongzi battle - guess who can win
随机推荐
Sql Server 数据库之初学体验
使用flex实现左中右布局,中间自适应
shell 脚本 失败自动重复执行
RT thread learning notes (V) -- edit, download and debug programs
WIRESHARK基础教程以太帧的分析。
C language callback function
如何实现临时的图形要素现实
Build ARM embedded development environment
C#halcon用户控件崩溃的一种处理方法
Error[Pe147]: declaration is incompatible with '错误问题
winpcap 抓包函数pcap_loop(),停止问题
Pengge C language lesson 4 (3)
Successfully transplanted stemwin v5.22 on Shenzhou IV development board
Flutter集成极光推送
RT thread learning notes (I) -- configure RT thread development environment
对面向抽象编程的理解
MFC多线程的简单使用
$router和$route的区别
20210807#1 C语言程序结构
SAP ABAP 守护进程的实现方式