3-9

#define _CRT_SECURE_NO_WARNINGS 

#include <iostream>
#include <cstdio>
#include <string>
#include <vector>

using namespace std;

int main()
{
    string s, t;
    while (cin >> s >> t) {
        
        int sLen = s.length();
        int tLen = t.length();
        
        if (sLen > tLen){
            cout << "No" << endl;
            continue;
        }

        int lastIndex = -1;
        int i = 0;
        for (i = 0; i < sLen; i++){
            bool found = false;
            for (int j = lastIndex + 1; j < tLen; j++) {
                if (s[i] == t[j]){
                    found = true;
                    lastIndex = j;
                    break;
                }
            }

            if (!found)
                break;
        }

        if (i == sLen)
            cout << "Yes" << endl;
        else
            cout << "No" << endl;
    }


    return 0;
}

 

posted @ 2016-07-25 19:23  PatrickZhou  阅读(122)  评论(0编辑  收藏  举报