Skip to content
LC-1941 Easy LeetCode

1941. Check if All Characters Have Equal Number of Occurrences

Read the full problem statement on LeetCode.
Difficulty: easy Acceptance: 79% Topics: Hash Table, String, Counting
View full problem on LeetCode
Reference solution (spoiler · python)
# Time:  O(n)
# Space: O(1)

import collections


class Solution(object):
    def areOccurrencesEqual(self, s):
        """
        :type s: str
        :rtype: bool
        """
        return len(set(collections.Counter(s).itervalues())) == 1

Solution from kamyu104/LeetCode-Solutions · MIT