题解中使用 string::substr\texttt {string::substr}string::substr,对每个位置截取子串进行比较。其实直接用 string::find\texttt {string::find}string::find 找子串即可。
for (auto &&now : s) { bool ok = true; for (auto &&tar : t) { if (now.find(tar) != string::npos) { ok = false; } } cout << (ok ? "No" : "Yes") << "\n"; }