### Game of Strings

#### Description:

Harsh and Akshara are playing the Game of Strings. This game is a simple one and is played as a team. Both the players of a team will be given a string respectively. At the end of this game, every team is required find out the length of the longest string S such that the strings given to each of the team members is a subsequence of S andS contains no vowels. Help Harsh and Akshara in finding out the required length. Input: Input consists of a single line containing two space separated strings. Output: The length of the longest string that satisfy the given conditions. Constraints: 1 <= length of string <=5000 Explanation The required string is "ng". if the constraint of the string S not containing vowels is removed, this becomes the classical Longest Common Subsequence (LCS) problem. For readers who are not familiar with LCS problem, they are encouraged to go through the following link which explains the problem as well to how to come up with the solution.http://en.wikipedia.org/wiki/Longest_common_subsequence_problem One can see that the LCS of the input two strings can never contain any vowels, hence, it is redundant to have vowels in the original string. Now, if we remove the vowels from the input strings, the problem is to find the length of the LCS of the edited strings. One can use the same approach described in the above wiki link to implement the solution. Test Case 1 Input (stdin) abbs aabbss Expected Output 3 Test Case 2 Input (stdin) mango mango Expected Output 3

#### Program :

#include<stdio.h>

#include<string.h>

long long a,b,i,j,array,x,y;

char name1,name2;

int main()

{

scanf("%s %s",name1,name2);

x=strlen(name1);

y=strlen(name2);

for(i=0;i<x;i++)

{

for(j=0;j<y;j++)

{

if(i==0)

{

if(j==0)

{

if(name1[i]==name2[j] && name2[j]!='a' && name2[j]!='e' && name2[j]!='i' && name2[j]!='o' && name2[j]!='u')

{

array[i][j]=1;

}

else

{

array[i][j]=0;

}

}

else if(j!=0)

{

if(name1[i]==name2[j] && name2[j]!='a' && name2[j]!='e' && name2[j]!='i' && name2[j]!='o' && name2[j]!='u')

{

array[i][j]=1;

}

else

{

array[i][j]=array[i][j-1];

}

}

}

else if(i!=0)

{

if(j==0)

{

if(name1[i]==name2[j] && name2[j]!='a' && name2[j]!='e' && name2[j]!='i' && name2[j]!='o' && name2[j]!='u')

{

array[i][j]=1;

}

else

{

array[i][j]=array[i-1][j];

}

}

else if(j!=0)

{

if(name1[i]==name2[j] && name2[j]!='a' && name2[j]!='e' && name2[j]!='i' && name2[j]!='o' && name2[j]!='u')

{

array[i][j]=array[i-1][j-1]+1;

}

else

{

a=array[i-1][j];

b=array[i][j-1];

if(a>=b)

{

array[i][j]=a;

}

else

{

array[i][j]=b;

}

}

}

}

}

}

printf("%lld\n",array[x-1][y-1]);

return 0;

}