-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHackerrankPsAlgorithms0079.java
More file actions
44 lines (33 loc) · 1.09 KB
/
HackerrankPsAlgorithms0079.java
File metadata and controls
44 lines (33 loc) · 1.09 KB
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
41
42
43
44
import java.io.*;
import java.util.*;
import java.util.stream.*;
public class HackerrankPsAlgorithms0079 {
// String Construction
// https://www.hackerrank.com/challenges/string-construction/problem?isFullScreen=true
static class Result {
public static int stringConstruction(String s) {
Set<Character> uniqueChars = new HashSet<>();
for (char c : s.toCharArray()) {
uniqueChars.add(c);
}
return uniqueChars.size();
}
}
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")));
int q = Integer.parseInt(bufferedReader.readLine().trim());
IntStream.range(0, q).forEach(qItr -> {
try {
String s = bufferedReader.readLine();
int result = Result.stringConstruction(s);
bufferedWriter.write(String.valueOf(result));
bufferedWriter.newLine();
} catch (IOException ex) {
throw new RuntimeException(ex);
}
});
bufferedReader.close();
bufferedWriter.close();
}
}