Skip to content

Commit 220ad0e

Browse files
authored
Create Rings and Rods.java
1 parent 5f0e323 commit 220ad0e

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Easy/Rings and Rods.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)