Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- Task : longest common subseq
- Author : Phumipat C. [MAGCARI]
- Language: C++
- Created : 31 December 2022 [10:53]
- */
- #include<bits/stdc++.h>
- using namespace std;
- char a[1010],b[1010];
- int dp[1010][1010];
- int main(){
- cin.tie(0)->sync_with_stdio(0);
- cin.exceptions(cin.failbit);
- cin >> a+1 >> b+1;
- int n = strlen(a+1),m = strlen(b+1);
- for(int i=1;i<=n;i++){
- for(int j=1;j<=m;j++){
- if(a[i] == b[j])
- dp[i][j] = dp[i-1][j-1]+1;
- // subsequence
- // dp[i][j] = max({dp[i][j],dp[i-1][j],dp[i][j-1]});
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment