1
class Solution {
2
public int countPoints(String rings) {
3
Map<Integer, Set<Character>> m = new HashMap<>();
4
for (int i = 0; i < rings.length(); i = i + 2) {
5
char c = rings.charAt(i);
6
int index = (int) rings.charAt(i + 1);
7
if (m.containsKey(index)) {
8
Set<Character> x = m.get(index);
9
x.add(c);
10
m.put(index, x);
11
} else {
12
Set<Character> x = new HashSet<>();
13
x.add(c);
14
m.put(index, x);
15
}
16
}
17
int count = 0;
18
for (Set<Character> k : m.values()) {
19
if (k.size() == 3) count++;
20
}
21
return count;
22
}
23
}

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0