Skip to content

Instantly share code, notes, and snippets.

@mohitkhosla01
Created October 13, 2016 12:01
Show Gist options
  • Save mohitkhosla01/bdd1cbff02079c9658b34845719c1e60 to your computer and use it in GitHub Desktop.
Save mohitkhosla01/bdd1cbff02079c9658b34845719c1e60 to your computer and use it in GitHub Desktop.
import java.util.Collections;
import java.util.Scanner;
import java.util.ArrayList;
public class gameOfThrones {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
String s=sc.next();
ArrayList<Character> arr=new ArrayList<Character>();
ArrayList<Character> t=new ArrayList<Character>();
for(int i=0;i<s.length();++i){
char ch=s.charAt(i);
arr.add(ch);
if(!t.contains(ch)){
t.add(ch);
}
}
boolean flag=true;
for(int i=0;i<t.size();++i){
int x=Collections.frequency(arr, t.get(i));
if(x%2!=0){
if(s.length()%2!=0 && flag==true){
flag=false;
}
else{
System.out.println("NO");
System.exit(0);
}
}
}
System.out.println("YES");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment