We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5f0e323 commit 220ad0eCopy full SHA for 220ad0e
Easy/Rings and Rods.java
@@ -0,0 +1,11 @@
1
+class Solution {
2
+ public int countPoints(String rings) {
3
+ Map<Integer, Set<Character>> map = new HashMap<>();
4
+ for (int i = 0; i < rings.length(); i += 2) {
5
+ char ring = rings.charAt(i);
6
+ int rod = Character.getNumericValue(rings.charAt(i + 1));
7
+ map.computeIfAbsent(rod, k -> new HashSet()).add(ring);
8
+ }
9
+ return (int) map.values().stream().filter(v -> v.size() == 3).count();
10
11
+}
0 commit comments