1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| class Solution { public: bool makeEqual(vector<string>& words) { const int n = words.size(); if (n == 1) return true; vector<int> cnt(26); for (auto& w : words) { for (auto c : w) { ++cnt[c - 'a']; } } for (int i = 0; i <= 25; ++i) if (cnt[i] && cnt[i] % n) return false; return true; } };
|