题解 | 月月查华华的手机

月月查华华的手机

https://www.nowcoder.com/practice/c2877187b1bb4573927e759a60f5d3e1

#include <iostream>
#include<string>
#include<unordered_map>
using namespace std;
//使用const string&来加快运行速度
bool judge(const string& A, const string& B) {
    int i = 0, j = 0;
    while (i < A.size() && j < B.size()) {
        if (A[i] == B[j]) {
            j++;
        }
        i++;
    }
    if(j == B.size())cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return true;
}
int main() {
    string str,sonstr;
    int n;
    cin>>str>>n;
    while(n--){
        cin>>sonstr;
        judge(str,sonstr);
    }
    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务