题解 | 公共子串计算
公共子串计算
https://www.nowcoder.com/practice/98dc82c094e043ccb7e0570e5342dd1b
import sys s = input() t = input() max_common_string_length = 0 if len(s) >= len(t): for i in range(len(s)): for j in range(i, len(t)): if t[i:j+1] in s and len(t[i:j+1]) > max_common_string_length: max_common_string_length = len(t[i:j+1]) else: for i in range(len(t)): for j in range(i, len(s)): if s[i:j+1] in t and len(s[i:j+1]) > max_common_string_length: max_common_string_length = len(s[i:j+1]) print(max_common_string_length)