✅ All you need is to count 😉
Intuition\n Describe your first thoughts on how to solve this problem. \n All we need to do is to count the number of each unique characters in all the given wo
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n* All we need to do is to count the number of each unique characters in all the given words.\n* And check if the number of these characters is divisible by the number of items in the given vector of words.\n\n* ie : if we have 2 words, s1 = "aaabbcccddd", s2="abbdddddc"\n* then number of items = 2.\n* unique chars are : a, b, c, d\n* lets count each of them \n    * a -> 3 in s1 + 1 in s2 = 4\n    * b -> 2 in s1 + 2 in s2 = 4\n    * c -> 4\n    * d -> 8.\n* since 4 and 8 and divisible by 2, so we can make the strings equal, so we should return true.    \n* but if s2 was = "bbdddddc"\n* now number of a will be 3, and 3 is not divisble by 2, so we will return false. \n* also if we have s1 and s2 same as before, and we have s3 = "a", then we can not make them equal because 8 and 4 are not divisible by 3. \n# Approach\n<!-- Describe your approach to solving the problem. -->\n1. create a map to count the number of each character. **You can also create an array of length 26, and it will be better in search, but i find this more easier.**\n2. iterate over each word in the given list\n    1. iterate over each character in the current word. \n        1. increment the coutner of that character. \n3. get the number of the words in the given list. \n4. iterate over each character in the map.\n    1. if its counter is not divisible by the size\n        1. return false.\n         \n5. return true.   \n# Complexity\n- Time complexity:\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n1. O(n*m + k), where \n    * n is the number of the words.\n    * m is the maximum number of characters in single word. \n    * k number of unique characters. \n- Space complexity:\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n1. O(k) -> O(26) -> the number of unique characters in english. \n# Code\n```\n#pragma GCC optimize("O3")\n#pragma GCC optimize("Ofast", "inline", "ffast-math", "unroll-loops", "no-stack-protector")\n#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native", "f16c")\nstatic const auto DPSolver = []()\n{ std::ios_base::sync_with_stdio(false); std::cin.tie(nullptr); std::cout.tie(nullptr); return \'c\'; }();\nclass Solution {\npublic:\n    bool makeEqual(vector<string> &words)\n    {\n        DPSolver; \n        map<char,int> mp; \n        for (string word : words)\n            for (char c : word)\n                mp[c]++; \n\n        int sz = words.size();\n        for (auto item : mp)\n            if (item.second % sz)\n                return false; \n        return true; \n    }\n};\n```
['Hash Table', 'String', 'Counting', 'C++']