Daily Question || JAVA || PYTHON || BEATS 100%
Intuition\nThe idea behind the solution is to count the occurrences of each character in the array of strings and ensure that the count of each character is a m
# Intuition\nThe idea behind the solution is to count the occurrences of each character in the array of strings and ensure that the count of each character is a multiple of the total number of strings. If this condition is met for every character, it means that it\'s possible to make every string in the array equal by moving characters between strings.\n\n# Approach\n- If there is only one string in the array, it is always possible to make every string equal (since there is only one string).\n\n- Calculate the total character count in all the strings in the array.\n\n- If the total character count is not divisible evenly by the number of strings, it\'s not possible to make every string equal, and the function returns false.\n\n- Create an array myMap of size 26 (assuming lowercase English letters). Traverse each string in the array and update the count of each character in myMap.\n\n- For each count in myMap, check if it is divisible evenly by the number of strings. If any count is not divisible evenly, return false.\n\n- If all counts are divisible evenly, return true.\n# Complexity\n- Time complexity: O(n+m)\n- Space complexity: O(1)\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```java []\nclass Solution {\n    public boolean makeEqual(String[] words) {\n        if (words.length == 1)\n\t\t\treturn true;\n\n\t\tint totalCharCount = 0;\n\t\tfor (String s : words)\n\t\t\ttotalCharCount += s.length();\n\n\t\tif (totalCharCount % words.length != 0)\n\t\t\treturn false;\n\n\t\tint[] myMap = new int[26];\n\t\tfor (String s : words)\n\t\t\tfor (char c : s.toCharArray())\n\t\t\t\tmyMap[c - \'a\']++;\n\n\t\tfor (int i : myMap)\n\t\t\tif (i % words.length != 0)\n\t\t\t\treturn false;\n\n\t\treturn true; \n    }\n}\n```\n```python []\nclass Solution:\n    def makeEqual(self, words: List[str]) -> bool:\n        if len(words) == 1:\n            return True\n\n        total_char_count = 0\n        for s in words:\n            total_char_count += len(s)\n\n        if total_char_count % len(words) != 0:\n            return False\n\n        my_map = [0] * 26\n        for s in words:\n            for c in s:\n                my_map[ord(c) - ord(\'a\')] += 1\n\n        for count in my_map:\n            if count % len(words) != 0:\n                return False\n\n        return True\n```
['Java', 'Python3']