๋ฌธ์
https://www.acmicpc.net/problem/5582
ํ์ด
# ๋ฐฑ์ค 5582๋ฒ ๋ฌธ์ - ๊ณตํต ๋ถ๋ถ ๋ฌธ์์ด
answer = 0
str1, str2 = input(), input()
dp=[[0] * (len(str2) + 1) for _ in range(len(str1) + 1)]
for i in range(1, len(str1)+1):
for j in range(1, len(str2)+1):
if (str1[i-1] == str2[j-1]):
dp[i][j] = dp[i-1][j-1] + 1
answer = max(dp[i][j], answer)
print(answer)
'๐๏ธ Algorithm > ๐ฉ ๋ฐฑ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 2225๋ฒ_ํฉ ๋ถํด (0) | 2023.04.27 |
---|---|
๐ฉ [๋ฐฑ์ค] [Python] [Gold5] 1916๋ฒ_์ต์๋น์ฉ ๊ตฌํ๊ธฐ (0) | 2023.04.27 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver1] 6588๋ฒ_๊ณจ๋๋ฐํ์ ์ถ์ธก (0) | 2023.04.25 |
๐ฉ [๋ฐฑ์ค] [Python] [Gold1] 2042๋ฒ_๊ตฌ๊ฐ ํฉ ๊ตฌํ๊ธฐ (0) | 2023.04.24 |
๐ฉ [๋ฐฑ์ค] [Python] [Silver3] 11478๋ฒ_์๋ก ๋ค๋ฅธ ๋ถ๋ถ ๋ฌธ์์ด์ ๊ฐ์ (0) | 2023.04.23 |