Beat 98% user in Python and 99.23% in C++
Intuition\nPYTHON and PYTHON 3:\n\n1. Counter Initialization : counter = Counter(): This creates an instance of the \'Counter\' class, which is a built-in Pytho
# Intuition\nPYTHON and PYTHON 3:\n\n1. Counter Initialization : counter = Counter(): This creates an instance of the \'Counter\' class, which is a built-in Python class for counting occurrences of elements. The \'counter\' variable will be used to count the occurrences of individual characters in the words.\n\n2. Character Counting : \n    1. \'for i in words:\' : This is a loop that iterates over each     word in the \'words\' list.\n    2. \'for j in i:\' : This is an inner loop that iterates over each character in the current word.\n    3. \'counter[j] += 1\': This increments the count of the character \'j\' in the \'counter\' dictionary.\n\n3. Calculation of \'n\': \'n = len(words)\' : This calculates the total number of words in the input list.\n\n4. Check for Equal Distribution : \'all(count % n == 0 for count in counter.values())\' : This is a generator expression inside the \'all\' function. It checks if the counts of each unique character in the words are divisible by the total number of words (\'n\').If all characters satisfy this condition, the function returns \'True\'; otherwise, it returns \'False\'.\n\n\nC++:\n\n1. Counter Initialization : An unordered_map named \'counter\' is declared to store the counts of each character.\n\n2. Character Counting:\n    1. The code uses nested loops to iterate over each character in each word in the vector \'words\'.\n    2. For each character, the count in the \'counter\' map is incremented.\n\n3. Total Number of Words (n) : The variable \'n\' is assigned the total number of words in the \'words\' vector.\n\n4. Check for Equal Distribution:\n    1. The code then iterates over the entries in the \'counter\' map using a range-based for loop.\n    2. For each character count, it checks if the count is divisible by the total number of words (\'n\').\n    3. If any count is not divisible, the function returns \'false\', indicating that the counts are not equal.\n    4. If all counts are divisible, the function returns \'true\', indicating that the counts are equal.\n\n\n# Approach\nCounting \n\n# Complexity\n- Time complexity:  O(n*m), where n is the total number of characters across all words in the input list words, and m is the average length of the words.\n\n- Space complexity: O(c) where \'c\' is the total number of unique characters in all words.\n\n# Code\n```C++ []\nclass Solution {\npublic:\n    bool makeEqual(vector<string>& words) {\n        unordered_map<char,int> counter;\n\n        for(const std::string& word:words) {\n            for (char ch : word) {\n                counter[ch]++;\n            }\n        }\n\n        int n = words.size();\n\n        for (const auto& pair : counter) {\n            if (pair.second % n != 0) {\n                return false;\n            }\n        }\n\n        return true;\n    }\n};\n```\n```python []\nclass Solution(object):\n    def makeEqual(self, words):\n        """\n        :type words: List[str]\n        :rtype: bool\n        """\n        counter=Counter()\n        for i in words:\n            for j in i:\n                counter[j]+=1\n        n=len(words)\n        return all(count%n==0 for count in counter.values())\n```\n```python3 []\nclass Solution:\n    def makeEqual(self, words: List[str]) -> bool:\n        counter=Counter()\n        for i in words:\n            for j in i:\n                counter[j]+=1\n        n=len(words)\n        return all(count%n==0 for count in counter.values())\n```
['Python', 'C++', 'Python3']