题解 | #查找兄弟单词#

查找兄弟单词

https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68

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
    const strs = await readline();
    const list = strs.split(' ');
    const num = +list[0];
    const arr = list.slice(1, 1 + num);
    const x = list[list.length - 2];
    const k = +list[list.length - 1];
    let words = arr.filter(ele=> ele.split('').sort().join('') === x.split('').sort().join('') && ele !== x);
    console.log(words.length);
    if(words.sort()[k - 1]) console.log(words.sort()[k - 1]);
}()

全部评论

相关推荐

04-25 19:29
已编辑
宁波大学 运营
被普调的六边形战士很高大:你我美牛孩
点赞 评论 收藏
分享
野猪不是猪🐗:我assume that你must技术aspect是solid的,temperament也挺good的,however面试不太serious,generally会feel style上不够sharp
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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