题解 | #DNA序列#

DNA序列

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


# import sys
while True:
    try:
        s = input()
        N = int(input())
        counts = {}
        maxCount = 0
        res = ''
        #计算每个字符开头的N个字符的GC个数,如果更大就保存到最大的值里
        for i in range(len(s) - N + 1):
            com_s = s[i:i+N]
            count = com_s.count('C') + com_s.count('G')
            if count > maxCount:
                maxCount = count
                res = com_s
        print(res)
    except:
#         print(sys.exc_info())
        break















全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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