-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy path802G - Fake News (easy).cpp
48 lines (33 loc) · 1.08 KB
/
802G - Fake News (easy).cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*
As it's the first of April, Heidi is suspecting that the news she reads today are fake, and she does not want to look silly in front of all the contestants. She knows that a newspiece is fake if it contains heidi as a subsequence. Help Heidi assess whether the given piece is true, but please be discreet about it...
Input
The first and only line of input contains a single nonempty string s of length at most 1000 composed of lowercase letters (a-z).
Output
Output YES if the string s contains heidi as a subsequence and NO otherwise.
Examples
inputCopy
abcheaibcdi
outputCopy
YES
inputCopy
hiedi
outputCopy
NO
Note
A string s contains another string p as a subsequence if it is possible to delete some characters from s and obtain p.
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
string s;
cin >> s;
string search = "heidi";
int j = 0;
for (int i = 0; i < s.length(); i++) {
if (s[i] == search[j]) j++;
}
j == search.length() ? cout << "YES\n" : cout << "NO\n";
return 0;
}