leetcode 383. Ransom Note
bool canConstruct(string ransomNote, string magazine) { unordered_map<char, int> m; for (auto i : magazine) m[i]++; for (auto i : ransomNote) { if (m[i] == 0) return false; m[i]--; } return true; }
【本文章出自博客园willaty,转载请注明作者出处,误差欢迎指出~】