all in
Description
Have devised a new encryption technique which encodes a message by inserting between its characters randomly Strings in a clever way. Because of pending patent issues we won't discuss in detail how the strings are generated and inserted into the Origina L message. To validate your method, however, it's necessary to write a program that's checks if the message was really encoded in the F Inal string.
Given two strings s and T, you are have to decide whether s are a subsequence of T, i.e. if you can remove characters from T su Ch that concatenation of the remaining characters is S.
Input Specification
The input contains several testcases. Each is specified by two strings s, T of alphanumeric ASCII characters separated by whitespace. The Input is terminated by EOF.
Output Specification
For each test case output, if s a subsequence of T.
Sample Input
Sequence subsequence
Person compression
VERDI Vivavittorioemanuelerediitalia
Casedoesmatter Casedoesmatter
Sample Output
Yes
No
Yes
No
Compare one by one, and skip the current character comparison next if you can't.
#include <stdio.h>
#include <string.h>
int main ()
{
char s[100001], t[100001];
while (scanf ("%s", S, t)!=eof)
{
int len_t=strlen (t), Len_s=strlen (s);
int count_s=0;
for (int i=0; i<len_t; i++)
{
if (s[count_s]==t[i))
count_s++;
}
if (count_s = = len_s)
printf ("yes\n");
else
printf ("no\n");
}
return 0;
}