forked from alexprut/HackerRank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSolution.java
More file actions
33 lines (27 loc) · 681 Bytes
/
Copy pathSolution.java
File metadata and controls
33 lines (27 loc) · 681 Bytes
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
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static String find(String s) {
String match = "hackerrank";
if (s.length() < match.length()) { return "NO"; }
int i = 0; int j = 0;
while (i < s.length()) {
if (s.charAt(i) == match.charAt(j)) { j++; }
i++;
if (j == match.length()) { break; }
}
if (j < match.length()) { return "NO"; }
return "YES";
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int q = in.nextInt();
for(int a0 = 0; a0 < q; a0++){
String s = in.next();
System.out.println(Solution.find(s));
}
}
}