-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGame_of_Thrones_I.java
80 lines (73 loc) · 1.67 KB
/
Game_of_Thrones_I.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
import java.util.ArrayList;
public class Game_of_Thrones_I{
public static void main(String[] args) {
Scanner st=new Scanner(System.in);
String string="";
ArrayList<Integer> occur = new ArrayList<Integer>();
String s=st.next();
int distinct = 0 ;
int c=0,w,j;
boolean found=false;
int one=0;
int two=0;
int length=s.length();
char[] z=new char[s.length()];
for(w=0;w<s.length();w++)
z[w]=s.charAt(w);
for(int i=0;i<w;i++)
{
char ch=z[i];
for(j=i+1;j<w;j++)
{
if(z[j]==ch)
{
for(int k=j;k<(w-1);k++)
z[k]=z[k+1];
w--;
j=i;
}
}
}
int[] t=new int[w];
for(int i=0;i<w;i++)
{
for(j=0,c=0;j<s.length();j++)
{
if(z[i]==s.charAt(j))
c++;
}
occur.add(c);
// System.out.print(z[i]+"="+occur.get(i)+",");
}
if(length%2==0)
{
for(int k=0;k<occur.size();k++)
{
if(occur.get(k)%2==0)
found=true;
else{
found=false;
break;
}
}
if(found)System.out.println("YES");
else System.out.println("NO");
}else{
for(int k=0;k<occur.size();k++)
{
if(occur.get(k)%2==1)
one++;
else{
two++;
}
}
if(one==1)System.out.println("YES");
else System.out.println("NO");
}
}
}