[規格]9251号:LCS(Python Python Python Python Python Python)
5733 ワード
👉 9251号:LCS
マイコード
# 골드 5레벨 LCS
from sys import stdin
read = stdin.readline
str1 = list(read().strip())
str2 = list(read().strip())
dp = [[0] * (len(str1) + 1) for _ in range(len(str2) + 1)]
for x in range(1, len(str2) + 1):
for y in range(1, len(str1) + 1):
if str1[y - 1] == str2[x - 1]:
dp[x][y] = dp[x - 1][y - 1] + 1
else:
dp[x][y] = max(dp[x - 1][y], dp[x][y - 1])
print(dp[len(str2)][len(str1)])
チップ
Reference
この問題について([規格]9251号:LCS(Python Python Python Python Python Python)), 我々は、より多くの情報をここで見つけました https://velog.io/@coding_egg/백준-9251번-LCS-python-파이썬テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol