题解 | #DNA序列#

DNA序列

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

while True:
    try:
        s, n = input(), int(input())
    except:
        break
    dict01 = {}  # 键:字符串 值: CG频次
    for i in range(len(s) - n + 1):
        dict01[s[i:i+n]] = 0
        for j in s[i:i+n]:
            if j == 'C' or j == 'G':
                dict01[s[i:i + n]] +=1
    r = max(dict01, key=lambda x:dict01[x])
    print(r)

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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