LeetCode 1941. Check if All Characters Have Equal Number of Occurrences Posted on 2021-07-25 Edited on 2024-11-24 In LeetCode 1234567891011121314class Solution {public: bool areOccurrencesEqual(string s) { int c[26] = {0}; for (char ch : s) ++c[ch - 'a']; int m = 0; for (int x : c) if (x) { m = max(m, x); if (m != x) return false; } return true; }};