|hash 散列字符串 要|1092 To Buy or Not to Buy (20分)
作者:互联网
#include <string>
#include <iostream>
using namespace std;
int const MAXN = 100010;
int hashTable[MAXN] = { 0 };
int miss = 0;
int main() {
string s1, s2;
getline(cin, s1);
getline(cin, s2);
for (int i = 0; i < s1.length(); i++) {
hashTable[s1[i]]++;
}
for (int i = 0; i < s2.length(); i++) {
//if (hashTable[s1[i]] != 0) {
// hashTable[s1[i]]--;
//}
hashTable[s2[i]]--;
if (hashTable[s2[i]] < 0)
miss++;
}
if (miss == 0)
cout << "Yes " << s1.length() - s2.length();
else
cout << "No " << miss;
return 0;
}
标签:Buy,hash,1092,int,s2,s1,++,hashTable,miss 来源: https://blog.csdn.net/weixin_44769957/article/details/112970738