C++,codeforces, 58A, Chat rooms

/*
codeforces, 58A, Chat rooms
判断一个字符串是否可以通过移除若干个字符得到 hello
输入一个字符串
输出YES或者NO
*/

/*
遍历输入字符串看能否按顺序得到h,e,l,l,o这五个字符
*/
#include <iostream>
#include <string>
int main(){
    std::string str;std::cin>>str;
    std::string hello = "hello";
    int index = 0;
    for(auto ch : str){
        if(ch == hello[index]){
            index++;
            if(index==5)break;
        }
    }
    if(index==5){
        std::cout<<"YES";
    }else{
        std::cout<<"NO";
    }
}
posted @ 2025-03-07 20:12  Kazuma_124  阅读(7)  评论(0)    收藏  举报