Skip to content

Commit 8e141c9

Browse files
Create 1897-redistribute-characters-to-make-all-strings-equal.java
1 parent 0cf38f0 commit 8e141c9

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
class Solution {
2+
public boolean makeEqual(String[] words) {
3+
Map<Character, Integer> map = new HashMap<>();
4+
5+
for(String s: words){
6+
for(char c: s.toCharArray()){
7+
map.put(c, map.getOrDefault(c, 0) + 1);
8+
}
9+
}
10+
int n = words.length;
11+
for(char c: map.keySet()){
12+
if(map.get(c) % n != 0)
13+
return false;
14+
}
15+
return true;
16+
}
17+
}

0 commit comments

Comments
 (0)