Python题解 | #公共子串计算#
公共子串计算
https://www.nowcoder.com/practice/98dc82c094e043ccb7e0570e5342dd1b
import sys import re while True: try: s1 = input().strip() s2 = input().strip() if len(s1) < len(s2): a = s2 s2 = s1 s1 = a ans = 0 for i in range(len(s2)): for j in range(i + 1, len(s2) + 1): if s1.find(s2[i:j]) != -1: ans = max(j - i, ans) print(ans) except: break