Created
October 13, 2016 12:01
-
-
Save mohitkhosla01/bdd1cbff02079c9658b34845719c1e60 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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