Leetcode 2053 Solution

This article provides solution to leetcode question 2053 (check-if-all-characters-have-equal-number-of-occurrences)

https://leetcode.com/problems/check-if-all-characters-have-equal-number-of-occurrences

Solution

class Solution:
    def areOccurrencesEqual(self, s: str) -> bool:
        m = collections.defaultdict(int)
        for ch in s:
            m[ch] += 1

        return len(set(m.values())) == 1