题解 | #DNA序列#

DNA序列

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

const rl = require("readline").createInterface({ input: process.stdin });
var iter = rl[Symbol.asyncIterator]();
const readline = async () => (await iter.next()).value;

void async function () {
    while(line = await readline()){
        let num = parseInt(await readline())
        let str = ''
        let max = 0
        for(let i=0; i<line.length-num+1; i++){
            let temp = line.substring(i,i+num)
            let length = 0
            temp.replace(/[CG]/g,(match)=>{
                length++
                if(length>max){
                    max = length
                    str = temp
                }
            })
        }
        console.log(str);
    }
}()

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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