문제 URL : https://www.softeer.ai/practice/6259
문제 접근법 :
lcs 아는 문제인지 물어보는 문제입니다.
lcs는 연속되지않는 부분문자도 포함하는 알고리즘이라
약간 변형이 필요합니다.
소스코드 :
import sys
input = sys.stdin.readline
n,m,k = map(int,input().split())
l = list(map(int,input().split()))
l2 = list(map(int,input().split()))
dp = [[0]*(m+1) for i in range(n+1)]
res = 0
for i in range(1,n+1):
for j in range(1,m+1):
if l[i-1]==l2[j-1]:
dp[i][j]=dp[i-1][j-1]+1
res = max(res,dp[i][j])
print(res)
궁금한점 혹은 모르는점 어떤질문이든 댓글은 언제나 환영입니다.
'Softeer' 카테고리의 다른 글
Softeer 조립라인 (c++) (1) | 2024.12.02 |
---|---|
Softeer [HSAT 5회 정기 코딩 인증평가 기출] 업무 처리(c++) (0) | 2024.12.02 |
Softeer 장애물 인식 프로그램 (2) | 2024.12.01 |
Softeer 우물 안 개구리 (python 풀이) (0) | 2024.12.01 |
Softeer GINI야 도와줘 c++ (2) | 2024.11.15 |