1 Star 1 Fork 22

Hillium/一个 Git 远程仓库

forked from xydhw/游戏部 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
lcs.py 702 Bytes
一键复制 编辑 原始数据 按行查看 历史
Hillium 提交于 2018-09-09 15:34 . 琐碎的修改集合。
from functools import lru_cache
@lru_cache(None)
def lcs(s1, s2, s1pos=None, s2pos=None):
if s1pos is None:
print(f"<1>: {len(s1) - 1}")
s1pos = len(s1) - 1
if s2pos is None:
print(f"<2>: {len(s2) - 1}")
s2pos = len(s2) - 1
if s1pos < 0 or s2pos < 0:
return 0
elif s1[s1pos] == s2[s2pos]:
return 1 + max(lcs(s1, s2, s1pos=s1pos-1, s2pos=s2pos), lcs(s1, s2, s1pos=s1pos, s2pos=s2pos-1))
else:
return max(lcs(s1, s2, s1pos=s1pos-1, s2pos=s2pos), lcs(s1, s2, s1pos=s1pos, s2pos=s2pos-1))
print(lcs('wekomfiowefmeowijfiowmfoiewmfoiwemfoiew',
'vewoijfioewfmncoqwimfcoweifnewiufnwiefcmnwiu'))
print(lcs.cache_info())
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C
1
https://gitee.com/Hillium/game_department.git
git@gitee.com:Hillium/game_department.git
Hillium
game_department
一个 Git 远程仓库
master

搜索帮助

23e8dbc6 1850385 7e0993f3 1850385