题解 | #DNA序列#
DNA序列
https://www.nowcoder.com/practice/e8480ed7501640709354db1cc4ffd42a
DNA = input() # 输入DNA序列
N = int(input()) # 输入子串的长度
str = [] # 存储切片后的子串
GC_Ratio = [] # 存储GC的占比,即GC-Ratio
#遍历位置
for i in range(len(DNA)):
str.append(DNA[i:i+N]) # 切片
sum = DNA[i:i+N].count('G') + DNA[i:i+N].count('C') # G和C出现的次数总和
GC_Ratio.append(sum / N) # GC-Ratio
x = max(GC_Ratio) # 最大占比
# 打印最大占比所在的子串
print(str[GC_Ratio.index(x)])
联想公司福利 1500人发布