1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-09 15:59:06 +01:00
LeetCode/java/redistribute-characters-to-make-all-strings-equal.java
Matej Focko f0cdb67ac1
chore(java): format
Signed-off-by: Matej Focko <mfocko@redhat.com>
2024-03-02 21:01:53 +01:00

20 lines
372 B
Java

class Solution {
public boolean makeEqual(String[] words) {
int[] counters = new int[26];
for (String w : words) {
for (int i = 0; i < w.length(); ++i) {
++counters[w.charAt(i) - 'a'];
}
}
int N = words.length;
for (int count : counters) {
if (count % N != 0) {
return false;
}
}
return true;
}
}