一行数据包括一个较短的字符串S和一个较长的字符串T,用一个空格分隔。保证1<=|S|<=|T|<=100000。
如果短的字符串可以由长字符串中的字符构建出来,输出字符串 “true”,否则输出字符串 "false"。
a b
false
fj jfiejfiejfie
true
#include <stdio.h>
#include <stdlib.h>
int main(void) {
char s[100000] = "", t[100000] = "";
scanf("%s %s", s, t);
int counts[26] = { 0 };
const char* p = t;
while (*p) ++counts[*p++ - 97];
p = s;
while (*p) --counts[*p++ - 97];
int i;
for (i = 0; i < 26; ++i)
if (counts[i] < 0)
return puts("false"), 0;
return puts("true"), 0;
}