题解 | 重复的DNA序列
# # 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可 # # # @param DNA string字符串 1 # @return string字符串一维数组 # class Solution: def repeatedDNA(self , DNA: str) -> List[str]: # write code here n=len(DNA) dic={} result="" for right in range(n): result+=DNA[right] if right<10-1: continue if result not in dic: dic[result]=1 else: dic[result]+=1 result=result[1:] res=[] for key in dic.keys(): if dic[key]>1: res.append(key) return res