🐣 공통 부분 문자열
1. 문제 링크
2. 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
import sys
input = sys.stdin.readline
fir_str = input().rstrip()
sec_str = input().rstrip()
dp = [[0 for _ in range(len(fir_str) + 1)] for _ in range(len(sec_str) + 1)]
for i in range(len(sec_str)):
for j in range(len(fir_str)):
if sec_str[i] == fir_str[j]:
dp[i + 1][j + 1] = dp[i][j] + 1
answer = 0
for d in dp:
answer = max(answer, max(d))
print(answer)
This post is licensed under CC BY 4.0 by the author.