package com.fishercoder.solutions;

import java.util.HashSet;
import java.util.Set;

public class _1941 {
    public static class Solution {
        public boolean areOccurrencesEqual(String s) {
            int[] counts = new int[26];
            for (char c : s.toCharArray()) {
                counts[c - 'a']++;
            }
            Set<Integer> set = new HashSet<>();
            for (int i : counts) {
                if (i != 0) {
                    set.add(i);
                }
            }
            return set.size() == 1;
        }
    }
}

@@ -46,23 +46,22 @@
 va.util.
-HashSet
+Arrays
 ;%0Aimport
@@ -71,19 +71,33 @@
 va.util.
-Set
+stream.Collectors
 ;%0A%0Apubli
@@ -258,37 +258,79 @@
     
-for (char c : s.toCharArray()
+char%5B%5D charArray = s.toCharArray();%0A            for (char c : charArray
 ) %7B%0A
@@ -394,195 +394,92 @@
     
-Set%3CInteger%3E set = new HashSet%3C%3E();%0A            for (int i : counts) %7B%0A                if (i != 0) %7B%0A                    set.add(i);%0A                %7D%0A            %7D%0A            return set
+return Arrays.stream(counts).filter(i -%3E i != 0).boxed().collect(Collectors.toSet())
 .siz

refactor 1941