forked from xtaci/algorithms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGameOfThrone.java
More file actions
40 lines (31 loc) · 964 Bytes
/
Copy pathGameOfThrone.java
File metadata and controls
40 lines (31 loc) · 964 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
29
30
31
32
33
34
35
36
37
38
39
40
//https://www.hackerrank.com/contests/ieeextreme-challenges/challenges/game-of-thrones/submissions/code/4149531
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
private static boolean isPalindrom(String input) {
int array[] = new int[255];
for (int i = 0; i < 255; i++)
array[i] = 0;
for(int i = 0; i < input.length() ; i++){
array[input.charAt(i)] +=1;
}
int odd = 0;
for (int i = 0; i < 255; i++) {
if (array[i] % 2 == 1) odd +=1;
}
if (odd <= 1) return true;
return false;
}
public static void main(String[] args) {
Scanner myScan = new Scanner(System.in);
String inputString = myScan.nextLine();
System.out.println(isPalindrom(inputString) ? "YES" : "NO");
// String ans;
// Assign ans a value of YES or NO, depending on whether or not inputString satisfies the required condition
// System.out.println(ans);
myScan.close();
}
}