[C++] Count Occurrences
Intuition\n Describe your first thoughts on how to solve this problem. \n- We can focus on how to redistribute characters and ignore how to move the characters\
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n- We can focus on how to redistribute characters and ignore how to move the characters\n- If the occurrence of each character is multiple of the number of words , where `n = words.size()`, then we can distribute them evenly to each word\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n- Count the occurrence for each character\n- Check whether we can distribute each character to each word evenly\n\n# Complexity\n- Time complexity: $$O({n}\\times{k})$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(1)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\npublic:\n    // time/space: O(nk)/O(1)\n    bool makeEqual(vector<string>& words) {\n        // count the occurrence for each character\n        unordered_map<int, int> char_count;\n        for (auto& word : words) {\n            for (auto& c : word) char_count[c]++;\n        }\n\n        // check whether we can distribute each character to each word evenly\n        for (auto [c, count] : char_count) {\n            if ((count % words.size()) != 0) return false;\n        }\n        return true;\n    }\n};\n```
['Hash Table', 'Counting', 'C++']