题解 | #DNA序列#

DNA序列

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

a = input()
b = int(input())

num_max = sum(1 if i in ['G','C'] else 0 for i in a[0:b])
num = num_max
j = 0
for i in range(0, len(a)-b):
    num = num + (1 if a[i+b] in ['G','C'] else 0) - (1 if a[i] in ['G','C'] else 0)
    if num > num_max:
        num_max = num
        j = i + 1

print(a[j:j+b])

全部评论

相关推荐

10-06 12:46
门头沟学院 Java
跨考小白:定时任务启动
点赞 评论 收藏
分享
评论
点赞
收藏
分享
牛客网
牛客企业服务