题解 | #公共子串计算#
公共子串计算
https://www.nowcoder.com/practice/98dc82c094e043ccb7e0570e5342dd1b
while True: try: strings1 = input() strings2 = input() if len(strings1) > len(strings2): strings1, strings2 = strings2, strings1 str_list = [] for i in range(len(strings1)): for j in range(1, len(strings1)+1-i): str = strings1[i:i+j] if str in strings2 and str not in str_list: str_list.append(str) result_list = sorted(str_list, key=lambda x: len(x), reverse=True) if result_list: result = len(result_list[0]) print(result) else: print('0') except: break