s1 = list(input())
s2 = list(input())
lcs = [[0] * (len(s2) + 1) for _ in range(len(s1) + 1)]
for i in range(1, len(s1)+1):
for j in range(1, len(s2)+1):
if s1[i-1] == s2[j-1]:
lcs[i][j] = lcs[i-1][j-1] + 1
else:
lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1])
print(max(map(max,lcs)))
'Algorithm > Python' 카테고리의 다른 글
[Algorithm|Python] 백준 1351번 (0) | 2025.02.22 |
---|---|
[Algorithm|Python] 백준 2225번 (0) | 2025.02.21 |
[Algorithm|Python] 백준 11053번 (0) | 2025.02.19 |
[Python|Algorithm] 백준 1003번 파이썬 (0) | 2025.02.18 |
[Algorithm|Python] 백준 19598번 / 99클럽 20일차 TIL (0) | 2025.02.15 |