forked from rajatgoyal715/Hackerrank
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameofThrones-I.java
More file actions
28 lines (27 loc) · 844 Bytes
/
GameofThrones-I.java
File metadata and controls
28 lines (27 loc) · 844 Bytes
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
import java.util.Scanner;
public class Solution {
public static void main(String[] args) {
Scanner myScan = new Scanner(System.in);
String inputString = myScan.nextLine();
String ans = "YES";
char word[] = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
int count[] = new int[26];
char a[] = inputString.toCharArray();
int l = inputString.length();
int c=0;
for(int i=0;i<26;i++){
for(int j=0;j<l;j++){
if(word[i]==a[j])
count[i]++;
}
if(count[i]%2!=0)
c++;
if(c>1){
ans = "NO";
break;
}
}
System.out.println(ans);
myScan.close();
}
}