187. Repeated DNA Sequences

class Solution(object):
    def findRepeatedDnaSequences(self, s):
        """
        :type s: str
        :rtype: List[str]
        """
        sequences=collections.defaultdict(int)
        for i in range(len(s)-9):
            sequences[s[i:i+10]]+=1
        return [key for key,val in sequences.iteritems() if val>1]
            
            

你可能感兴趣的:(187. Repeated DNA Sequences)