水题,从头到尾扫一遍就可以了,输入两个字符串s和t,判断是否可以从t中删除0个或多个字符(其他字符顺序不变),得到字符串s。例如,abcde可以得到bce,但无法得到dc。
#include<algorithm> #include<cstring> #include<cstdio> #include<iostream> #define len 101000 using namespace std; char s[len], t[len]; int main() { int sn, tn, ls, lt; while (cin >> s) { cin >> t; ls = strlen(s); lt = strlen(t); sn = 0;tn = 0; for (int i = 0;i < ls, i < lt;i++) { if (s[sn] == t[tn]) { sn++; tn++; } else { tn++; } } if (sn == ls)cout << "Yes" << endl; else cout << "No" << endl; } return 0; }
本文介绍了解决UVA10340问题的方法,该问题要求判断一个字符串是否可以从另一个字符串中通过删除部分字符得到。文章提供了C++代码实现,采用双指针技巧,遍历两个字符串,检查是否满足条件。

417

被折叠的 条评论
为什么被折叠?



