-
Notifications
You must be signed in to change notification settings - Fork 0
/
CF58A.java
37 lines (36 loc) · 1.19 KB
/
CF58A.java
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
import java.util.Scanner;
public class CF58A {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
if(s.length() <= 4) {
System.out.println("NO");
} else {
StringBuilder sb = new StringBuilder("");
int h = 1;
int e = 1;
int l = 2;
int o = 1;
for(int i = 0; i < s.length(); i++) {
if(h > 0 && s.charAt(i) == 'h') {
sb.append('h');
h--;
} else if(h == 0 && e > 0 && s.charAt(i) == 'e') {
sb.append('e');
e--;
} else if(h == 0 && e == 0 && l > 0 && s.charAt(i) == 'l' ) {
sb.append('l');
l--;
} else if(h == 0 && e == 0 && l == 0 && o > 0 && s.charAt(i) == 'o') {
sb.append('o');
o--;
} else {
continue;
}
}
if( "hello".equals(new String(sb))) System.out.println("YES");
else System.out.println("NO");
}
sc.close();
}
}