题解 | #字符串字符匹配#

字符串字符匹配

https://www.nowcoder.com/practice/22fdeb9610ef426f9505e3ab60164c93

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    const str1 = await readline();
    const str2 = await readline();
    const [longStr,shortStr] = str1.length>str2.length?[str1,str2]:[str2,str1];
    const set = new Set(longStr);
    for(const c of shortStr){
        if(!set.has(c)) return console.log(false);
    }
    return console.log(true);
}()

全部评论

相关推荐

评论
1
1
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务