-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathChatRoom.java
More file actions
37 lines (33 loc) · 1.06 KB
/
ChatRoom.java
File metadata and controls
37 lines (33 loc) · 1.06 KB
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
/**
* Created by MalhotR1 on 2/10/2017.
*/
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
public class ChatRoom {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
char[] in = br.readLine().trim().toCharArray();
boolean[] hello = new boolean[5];
for (int i = 0; i < in.length; i++) {
if (in[i] == 'h' && !hello[0]) {
hello[0] = true;
}
else if (hello[0]&& in[i] == 'e') hello[1] = true;
else if (hello[1] && in[i] == 'l') {
if (hello[2]) hello[3] = true;
else hello[2] = true;
}
else if (hello[3] && in[i] == 'o') hello[4] = true;
}
for (int i = 0; i < 5; i++) {
if (!hello[i]) {
System.out.println("NO");
return;
}
}
System.out.println("YES");
}
}