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