All in all, UVa 10340

Source: Internet
Author: User

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;
}


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.