直方图的思想
static, const的变量
class Solution {
public:int countCharacters(const vector<string>& words, const string& chars) {int ret = 0;auto his = cntFreq(chars);for (auto& w : words)if (equal(his, cntFreq(w)))ret += w.size();return ret;}
private:inline vector<int> cntFreq(const string& s) {vector<int> cnt_freq(26, 0);for (char c : s)cnt_freq[c - 'a']++;return cnt_freq;}inline bool equal(const vector<int>& a, const vector<int>& b) {for (int i = 0; i < a.size(); i++)if (a[i] < b[i])return false;return true;}
};
static const auto speedup = []() {std::ios::sync_with_stdio(false); std::cin.tie(nullptr); return 0;
}();```