본문 바로가기
  • KEEP HUSTLE!
파이썬 코테 준비

[백준 9251] LCS - Python(파이썬)

by 하수군 2021. 3. 9.
import sys


def solution():
    for i in range(len(str1)):
        temp = 0
        for j in range(len(str2)):
            if temp < check[j]:
                temp = check[j]
            elif str1[i] == str2[j]:
                check[j] = temp + 1

    return max(check)


str1 = sys.stdin.readline().strip()
str2 = sys.stdin.readline().strip()
check = [0] * len(str2)

print(solution())

댓글