About Me

About Me : I have been working as a Software Engineer for various international companies for four years.Currently, I am working as a full stack Javascript developer in Petronas(Malaysia).

Skills

Skills • Javascript •Typescript •Python •C •Java •ReactJs • Redux • VueJs • NestJs • React Testing Library • Django• PostgreSQL • MySQL • NodeJs • Git • Docker • Jira • Visual Studio Code • Slack

শনিবার, ৩ জানুয়ারী, ২০১৫

UVA SOLUTION : 10405 - Longest Common Subsequence

#include <iostream>
#include<cstdio>
#include<cstring>

using namespace std;
int maxi(int a,int b)
{
    return a>b?a:b;
}
int lcs(char *a,char *b,int m,int n)
{
    int ar[m+1][n+1],i,j;

    for( i=0; i<=m; i++)
    {
        for(j=0; j<=n; j++)
        {
            if(i==0||j==0)
            {
                ar[i][j]=0;
                continue;
            }
            else if(a[i-1]==b[j-1]) ar[i][j]=ar[i-1][j-1]+1;
            else if(a[i-1]!=b[j-1]) ar[i][j]=maxi(ar[i-1][j],ar[i][j-1]);

        }
    }

 return ar[m][n];

}

int main()
{
     //freopen("in.txt","r",stdin);
    char a[1009],b[1009];
    int l1,l2,res;
    while(gets(a))
    {
        gets(b);
        l1=strlen(a);
        l2=strlen(b);
        res=lcs(a,b,l1,l2);
        printf("%d\n",res);

    }




    return 0;
}

কোন মন্তব্য নেই:

একটি মন্তব্য পোস্ট করুন