1092 To Buy or Not to Buy 解题代码测试结果问题整理 解题代码 #include<cstdio> #include<cstring> #include<iostream> #include<unordered_map> using namespace std; int main() { char a[1001], b[1001]; cin.getline(a, 1001); cin.getline(b, 1001); unordered_map<char, int> m; int len1 = strlen(a), len2 = strlen(b); for (int i = 0; i < len1; i++) m[a[i]]--; for (int i = 0; i < len2; i++) m[b[i]]++; int less = 0; for (auto x : m) if (x.second > 0) less += x.second; if (less) printf("No %d", less); else printf("Yes %d", len1 - len2); return 0; } 测试结果 问题整理 1.哈希。