-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathHackerRankinaString.java
More file actions
57 lines (57 loc) · 958 Bytes
/
HackerRankinaString.java
File metadata and controls
57 lines (57 loc) · 958 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import java.io.*;
import java.util.Scanner;
class HackerRankinaString
{
public static void main(String[]args)throws IOException
{
BufferedReader venki=new BufferedReader(new InputStreamReader(System.in));
int q=Integer.parseInt(venki.readLine());
for(int Q=0;Q<q;Q++)
{
String s=venki.readLine();
int i,c=0,H=0,A=0,C=0,E=0,R=0,N=0,K=0;
char ch;
for(i=0;i<s.length();i++)
{
ch=s.charAt(i);
if(ch=='h')
{
H++;
}
else if(ch=='a')
{
A++;
}
else if(ch=='c')
{
C++;
}
else if(ch=='k')
{
K++;
}
else if(ch=='e')
{
E++;
}
else if(ch=='r')
{
R++;
}
else if(ch=='n')
{
N++;
}
}
System.out.println("H :"+H+", A :"+A+", C :"+C+", K :"+E+", R :"+R+", N :"+N);
if(H>=1 && A>=2 && C>=1 && K>=2 && E>=1 && R>=2 && N>=1)
{
System.out.println("YES");
}
else
{
System.out.println("NO");
}
}
}
}