Skip to content

Commit 658cc17

Browse files
authored
Create Check if All Characters Have Equal Number of Occurrences.java
1 parent e4e589d commit 658cc17

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Solution {
2+
public boolean areOccurrencesEqual(String s) {
3+
return new HashSet<>(s.chars().mapToObj(c -> (char) c)
4+
.collect(Collectors.groupingBy(Function.identity(), HashMap::new, Collectors.counting()))
5+
.values()).size() == 1;
6+
}
7+
}

0 commit comments

Comments
 (0)