C# Solution for Redistribute Characters to Make All Strings Equal Problem
Intuition\n Describe your first thoughts on how to solve this problem. \nThe approach involves counting the occurrences of each character in all the words. If t
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\nThe approach involves counting the occurrences of each character in all the words. If the count of each character is a multiple of the total number of words, it implies that these characters can be distributed evenly among all words to make them equal.\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n1.\tInitialize an array to count the occurrences of characters (assuming lowercase English letters).\n2.\tIterate through each word in the array and increment the count for each character encountered.\n3.\tCheck if the count of each character is divisible by the total number of words. If any character count is not divisible, it\u2019s impossible to make all strings equal.\n\n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\u2022\tCounting the occurrences of characters in each word takes O(n * m) time, where n is the number of words and m is the average length of the words.\n\u2022\tChecking the divisibility for each character count takes O(26) or O(1) time because we assume a constant number of characters (26 lowercase English letters).\n\u2022\tTherefore, the overall time complexity is O(n * m) as it dominates the constant time.\n\n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\nThe array charCount of size 26 (assuming lowercase English letters) is used to store the count of occurrences of each character. Therefore, the space complexity is O(26), which simplifies to O(1), as it\u2019s a fixed size and independent of the input size.\n\n# Code\n```\npublic class Solution {\n    public bool MakeEqual(string[] words) {\n        int[] charCount = new int[26]; // Assuming lowercase English letters\n        \n        // Count occurrences of each character in the words\n        foreach (string word in words) {\n            foreach (char ch in word) {\n                charCount[ch - \'a\']++;\n            }\n        }\n        \n        int totalWords = words.Length;\n        \n        // Check if the count of each character is a multiple of the total number of words\n        foreach (int count in charCount) {\n            if (count % totalWords != 0) {\n                return false;\n            }\n        }\n        \n        return true;\n    }\n}\n```
['C#']