赎金信
代码实现:
哈希表
bool canConstruct(char *ransomNote, char *magazine) {int hash[26] = {0};for (int i = 0; i < strlen(ransomNote); i++) {hash[ransomNote[i] - 'a']++;}for (int i = 0; i < strlen(magazine); i++) {if (hash[magazine[i] - 'a']) {hash[magazine[i] - 'a']--;}}for (int i = 0; i < 26; i++) {if (hash[i]) {return false;}}return true; }