-
Notifications
You must be signed in to change notification settings - Fork 2
/
GameofThrones1.java
66 lines (65 loc) · 904 Bytes
/
GameofThrones1.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import java.io.*;
import java.util.Scanner;
import java.lang.*;
class GameofThrones1
{
public static void main(String[]args)throws IOException
{
BufferedReader venki=new BufferedReader(new InputStreamReader(System.in));
String str=venki.readLine();
int i,j,flag=0,c=0,l=str.length(),x=0;
if(l%2==0)
{
for(i=0;i<l;i++)
{
c=0;char chr=str.charAt(i);j=0;
while(j<l)
{
char ch=str.charAt(j);
if(chr==ch)
{
c++;
}
j++;
}
if(c<2)
{
flag=1;
}
}
}
else
{
for(i=0;i<l;i++)
{
c=0; char chr=str.charAt(i);
j=0;
while(j<l)
{
char ch=str.charAt(j);
if(chr==ch)
{
c++;
}
j++;
}
if(c<2)
{
x++;
}
if(x>1)
{
flag=1;
}
}
}
if(flag==1)
{
System.out.println("NO");
}
if(flag==0)
{
System.out.println("YES");
}
}
}