Game of Thrones - I Hackerrank Solution
import java.util.Scanner;
public class GameOfThrones {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String s = sc.next();
int[] val = new int[26];
for (int i = 0; i < s.length(); i++) {
int ch = s.charAt(i)-97;
val[ch]++;
}
int countOdd = 0;
for (int i = 0; i < val.length; i++) {
if(val[i]%2 != 0)
countOdd++;
if(countOdd > 1){
System.out.println("NO");
System.exit(0);
}
}
System.out.println("YES");
}
}
Comments
Post a Comment