https://pintia.cn/problem-sets/994805260223102976/problems/994805283241443328
思路
还是计数法,先统计有的,减去想要的,减到负数说明缺了,这时统计缺的数量。最后如果缺的数量大于0就输出NO,否则YES;
测试点2解决办法:不用fgets。(不知道什么原理)
#include <stdio.h>
#include <string.h>
int main()
{
int asc[128]={0},count=0;
char have[1001],want[1001];
scanf("%s%s",have,want);
int havelen=strlen(have),wantlen=strlen(want);
for (int i=0; i<havelen; i++)
asc[have[i]]++;
for (int i=0; i<wantlen; i++){
asc[want[i]]--;
if (asc[want[i]]<0)
count++;
}
if (!count>0)
printf("Yes %d",havelen-wantlen);
else
printf("No %d",count);
}