SPOJ EDIST Problem

Problem : Click here

My Code :: …

Blockquote

#include <bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
string A,B;
cin>>A>>B;
char w=‘q’;
long int a=A.size(),b=B.size();
long int c=max(a,b),d=min(a,b),z=0;
for(int i=0;i<a;i++)
{
for(int j=0;j<b;j++)
{
if(A.at(i)==B.at(j) && A.at(i)!=w && B.at(j)!=w)
{
z++;
A.at(i)=w;
B.at(j)=w;
}
}
}
cout<<c-z<<endl;
}
return 0;
}

Blockquote


I am new to Programming ! :confused:
So anyone please explain where i have gone wrong ?
Comments in the problem say that this problem requires dp.
i donno dp :frowning: (as i am new ) !
if this can’t be solved in the way i did and compulsorily requires dp.
Suggest me link to learn . Thanks in advance !!.

This is a standard DP problem.
take a look at this link