-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankPsAlgorithms0083.java
More file actions
38 lines (26 loc) · 1012 Bytes
/
HackerrankPsAlgorithms0083.java
File metadata and controls
38 lines (26 loc) · 1012 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
import java.io.*;
import java.util.*;
public class HackerrankPsAlgorithms0083 {
// Game of Thrones - I
// https://www.hackerrank.com/challenges/game-of-thrones/problem?isFullScreen=true
static class Result {
public static String gameOfThrones(String s) {
Map<Character, Integer> charCountMap = new HashMap<>();
for (char c : s.toCharArray()) {
charCountMap.put(c, charCountMap.getOrDefault(c, 0) + 1);
}
long oddCount = charCountMap.values().stream().filter(p -> p % 2 != 0).count();
return oddCount <= 1 ? "YES" : "NO";
}
}
public static void main(String[] args) throws IOException {
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in));
BufferedWriter bufferedWriter = new BufferedWriter(new FileWriter(System.getenv("OUTPUT_PATH")));
String s = bufferedReader.readLine();
String result = Result.gameOfThrones(s);
bufferedWriter.write(result);
bufferedWriter.newLine();
bufferedReader.close();
bufferedWriter.close();
}
}