题解 | #字符串字符匹配#
字符串字符匹配
https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93?tpId=37&tqId=21304&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D2%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=2&judgeStatus=undefined&tags=&title=
时间复杂度O(logN)
const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;
void (async function () {
// Write your code here
let index = 0;
let token2 = [];
let str = "";
while ((line = await readline())) {
str = str.concat(line); // 两行合并后的字符串
if (index === 0) index++;
else token2 = line.split("");
}
let result = false;
// 两行合并后的数组
let strArray = str.split("");
// 对合并后的数组和第二个数组分别去重
let strFinal = Array.from(new Set(strArray));
let token2Final = Array.from(new Set(token2));
// 如果这两个数组去重之后长度相同,说明第一个数组没有为合并后的数组提供新的元素,也就是第一个数组里的值在第二个数组里都有
if(strFinal.length===token2Final.length)result=true;
console.log(result);
})();
