题解 | #查找兄弟单词#

查找兄弟单词

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;
function sortW(word) {
    return word.split('').sort().join('')
}
void async function () {
    // Write your code here
    while(line = await readline()){
        let arr = line.split(' ')
        let n = arr.shift()
        let k = arr.pop()
        let x = arr.pop()
        let broX = arr.filter(el => el !== x && sortW(el) == sortW(x))
        
        console.log(broX.length)
        if (broX[k-1]) {
            broX.sort()
            console.log(broX[k-1])
        }
    }
}()

全部评论

相关推荐

白火同学:能。我当初应届沟通了1200,收简历50,面试10左右吧,加油投吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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