题解 | #公共子串计算#
公共子串计算
https://www.nowcoder.com/practice/98dc82c094e043ccb7e0570e5342dd1b
str1 = input().strip() str2 = input().strip() import sys if len(str1) > len(str2): tamp = str1 str1 = str2 str2 = tamp if str1 in str2: print(len(str1)) else: for i in range(len(str1)-1,0,-1): for j in range(len(str1)-i): if str1[j:j+i] in str2: print(i) sys.exit() else: print('0')