水题,就扫一遍就行。只不过有点没有注意,就是在s中某个字符与t中某个字符匹配了之后,在判断完之后,t的下标要++,否则就会使“sequencee sequence”也被判为Yes。
AC代码:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
int main()
{
char s[200005], t[200005];
// bool notbegin = false;
while (scanf("%s%s", s, t) != EOF)
{
int m = strlen(s), n = strlen(t);
int i, j;
bool flag = true;
for (i = 0, j = 0; i < m; i++)
{
for (; j < n; j++)
{
if (s[i] == t[j])
break;
}
if (j == n)
{
flag = false;
break;
}
j++;
}
// if (notbegin)
// printf("\n");
// notbegin = true;
if (flag)
printf("Yes\n");
else
printf("No\n");
}
// system("pause");
return 0;
}