#Ai Tool : DiaAi_bot
def longest_common_substring_recursive(s1, s2, i, j, count):
if i == 0 or j == 0:
return count
if s1[i-1] == s2[j-1]:
count = longest_common_substring_recursive(s1, s2, i-1, j-1, count + 1)
return max(count,
longest_common_substring_recursive(s1, s2, i-1, j, 0),
longest_common_substring_recursive(s1, s2, i, j-1, 0))
def lcs_substring(s1, s2):
n = len(s1)
m = len(s2)
return longest_common_substring_recursive(s1, s2, n, m, 0)
string1 = input()
string2 = input()
result = lcs_substring(string1, string2)
print(result)
این جواب برا سوال بالام درستع؟
پیام #Ai Tool : DiaAi_bot
30 مارس 2025در همان حوالی فید
Sاین پیام