#include <bits/stdc++.h>
#define fastio cin.tie(0)->sync_with_stdio(0)
using namespace std;
int dp [1001][1001];
string s1, s2;
int main(){
fastio;
cin>>s1>>s2;
for(int i=1; i<=s1.length(); i++){
for(int j=1; j<=s2.length(); j++){
if(s1[i-1] == s2[j-1]){
dp[i][j] = dp[i-1][j-1] +1;
}
else{
dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
}
}
}
cout<<dp[s1.length()][s2.length()];
return 0;
}
<참고>
'기타 > 백준일지' 카테고리의 다른 글
[백준] 1351번 무한 수열 (0) | 2025.02.21 |
---|---|
[백준] 2225번 합분해 (0) | 2025.02.20 |
[백준] 11404번 플로이드-마샬 (0) | 2025.02.18 |
[백준] 11053번 가장 긴 증가하는 수열 (0) | 2025.02.18 |
[백준] 1003번 피보나치 수열 (0) | 2025.02.17 |