Skip to content

Commit a79246a

Browse files
authored
Create redistribute-characters-to-make-all-strings-equal.py
1 parent 1d56686 commit a79246a

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
import collections
5+
6+
7+
class Solution(object):
8+
def makeEqual(self, words):
9+
"""
10+
:type words: List[str]
11+
:rtype: bool
12+
"""
13+
cnt = collections.defaultdict(int)
14+
for w in words:
15+
for c in w:
16+
cnt[c] += 1
17+
return all(v%len(words) == 0 for v in cnt.itervalues())

0 commit comments

Comments
 (0)