I-all in all

Source: Internet
Author: User

You are devised a new encryption technique which encodes a message by inserting between its characters randomly generated Strings in a clever. Because of pending patent issues we won't discuss in detail how the strings is generated and inserted into the Origina L message. To validate your method, however, it's necessary to write a program that checks if the message was really encoded in the F Inal string.

Given-Strings s and T, you had to decide whether s is a subsequence of T, i.e. if You can remove characters from T such so the concatenation of the remaining characters is s.

Input specification

The input contains several testcases. Each are specified by and strings s, T of alphanumeric ASCII characters separated by whitespace. Input is terminated by EOF.

Output specification

For each test, the output, if s is a subsequence of T.

Sample Input

Sequence subsequence
Person compression
VERDI Vivavittorioemanuelerediitalia
Casedoesmatter Casedoesmatter

Sample Output

Yes
No
Yes
No




Crying blind. It seems such a simple question ... Hidden a lot of pits. (But it should still be my poor technology.) First, the topic does not give the data range of the string, because this re is two times (〒_〒), do not give the scope of the problem must be the array to open. The second is that they think about the problem when thinking too simple, just simple sample on the submission, not in-depth thinking of other special circumstances, because this WA two times (〒_〒) (PS: Estimate their algorithm is too poor, so you need to consider a lot of situations).



#include <stdio.h>#include<string.h>Charstr1[1000000],str2[1000000];intMain () {intI,j,flag;  while(~SCANF ("%s%s", STR1,STR2)) {J=0; Flag=0;  for(i=0; I<strlen (str1); i++)        {             for(; J<strlen (str2); J + +)            {                if(str1[i]==Str2[j]) {                    if(I==strlen (STR1)-1) Flag=1;  Break; }} J++; }        if(flag==1) printf ("yes\n"); Elseprintf"no\n"); }    return 0;}

I-all in all

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.