题解 | #查找兄弟单词#
查找兄弟单词
https://www.nowcoder.com/practice/03ba8aeeef73400ca7a37a5f3370fe68
let inputstr = readline() let myarr = inputstr.split(' ') let targetstr = myarr[myarr.length-2] let targetbro = myarr[myarr.length-1] myarr.pop() && myarr.pop() && myarr.shift() let bro = [] let num = myarr.reduce((a,b) => { if(b.length==targetstr.length && b!=targetstr && b.split('').sort().join('')==targetstr.split('').sort().join('')){ a++ bro.push(b) } else{a+=0} return a }, 0) bro.sort() console.log(num) if(bro.length >= targetbro){ console.log(bro[targetbro-1]) }
#查找兄弟单词#