题解 | #查找兄弟单词#

查找兄弟单词

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-21 11:22
已编辑
中华女子学院 UE4
耐心学习_佩可officical:直接举报他,佬,违反劳动法我记得boss会下架
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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