### Maggu and Cuteness of Strings

below given code is for iitwpc4h spoj or Maggu and Cuteness of Strings spoj.

Here simple logic is behind this question at first you should know what is Subsequence .Then it is very simple you have to just find the

**maximum length of consecutive equal characters in both strings and add them up.**

#include <iostream> #include <cstring> #include <cstdlib> using namespace std; int main() { int d,i,j,lent,lens,maxlen,curlen,max; char t[200000],s[200000],cur; scanf("%d",&d); while(d--) { //cin>>t>>s; scanf("%s",t); scanf("%s",s); lent=strlen(t); lens=strlen(s); int *tlist=(int*)calloc(26,sizeof(int)); int *slist=(int*)calloc(26,sizeof(int)); cur=t[0]; curlen=1; tlist[cur-97]=1; for (i=1; i<lent; i++) { if (t[i]==cur) { curlen++; if (curlen>tlist[cur-97]) { tlist[cur-97]=curlen; } } else { cur=t[i]; curlen=1; if (curlen>tlist[cur-97]) { tlist[cur-97]=curlen; } } } cur=s[0]; curlen=1; slist[cur-97]=1; for (i=1; i<lens; i++) { if (s[i]==cur) { curlen++; if (curlen>slist[cur-97]) { slist[cur-97]=curlen; } } else { cur=s[i]; curlen=1; if (curlen>slist[cur-97]) { slist[cur-97]=curlen; } } } int *array=(int*)calloc(26,sizeof(int)); for (i=0; i<26; i++) array[i]=tlist[i]+slist[i]; max=-1; for (i=0; i<26; i++) if (max<array[i]) max=array[i]; printf("%d\n",max); } return 0; }