题解 | #查找两个字符串a,b中的最长公共子串#

查找两个字符串a,b中的最长公共子串

https://www.nowcoder.com/practice/181a1a71c7574266ad07f9739f791506

s1 = input()
s2 = input()
res = []
maxlen = 0
if len(s1) > len(s2):
    s1,s2 = s2,s1
for i in range(len(s1)):
    for j in range(len(s1)-i):
        sub = s1[j:i+j]
        if sub in s2 and len(sub)>maxlen:
            maxlen = len(sub)
            res=sub
print(res)

#华为机试#
全部评论

相关推荐

点赞 评论 收藏
分享
06-14 19:09
门头沟学院 Java
darius_:给制造业搞的,什么物料管理生产管理,设备管理点检,最最关键的就是一堆报表看板。个人觉得没啥技术含量都是些基本的crud,但是业务很繁琐那种
点赞 评论 收藏
分享
05-05 21:45
已编辑
广州大学 Java
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务