题解 | #单词倒排#

单词倒排

https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836?tpId=37&tqId=38366&rp=1&ru=/exam/oj/ta&qru=/exam/oj/ta&sourceUrl=%2Fexam%2Foj%2Fta%3Fdifficulty%3D2%26page%3D1%26pageSize%3D50%26search%3D%26tpId%3D37%26type%3D37&difficulty=2&judgeStatus=undefined&tags=&title=

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
    while ((line = await readline())) {
        let str = "";
        let arr = [];

        for (let i = 0; i < line.length; i++) {
            if (
                (line[i] >= "a" && line[i] <= "z") ||
                (line[i] >= "A" && line[i] <= "Z")
            ) {
                str = str.concat(line[i]);
            } else if (str !== "") {
                arr.push(str);
                str = "";
            }
            if(i===line.length-1)arr.push(str);
        }

        str = "";
        for(let i = arr.length-1;i>=0;i--){
            str=str.concat(arr[i]," ");
        }
        console.log(str);
    }
})();

全部评论

相关推荐

12-27 22:14
门头沟学院 Java
点赞 评论 收藏
分享
Jcwemz:中软证书写单行,考了什么学了什么相关技术栈的内容就说自己会什么, 没实习就包装实习简历,将项目经历写成实习做的,项目时间拉长,项目成果具体化,测试的项目成果无非就是写了多少用例查出了多少bug,重要的不是实习了多久,而是你会多少东西,你能表达的就都是你的。 cet4,随便找个地方标上就好了,不用写单行。 粗略建议,我也不在行,觉得对的可以采纳
实习,投递多份简历没人回...
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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