题解 | new Set() 对数组去重并保留原有顺序

字符串加密

https://www.nowcoder.com/practice/e4af1fe682b54459b2a211df91a91cf3

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
    let key = await readline()
    let str = await readline()
    let line = 'abcdefghijklmnopqrstuvwxyz'
    let pswStr = [...new Set(key + line)]
    
    let res = ''
    str.split('').forEach(el => {
        res += pswStr[line.indexOf(el)]
    })
    console.log(res)
}()

全部评论

相关推荐

05-29 22:11
门头沟学院 Java
Elastic90:抛开学历造假不谈,这公司的招聘需求也挺怪的,Java开发还要求你有图文识别、移动端开发和c++的经验,有点逆天了。
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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