My python solution to share (96ms)


  • 0
    L
    class Solution(object):
        def findRepeatedDnaSequences(self, s):
            """
            :type s: str
            :rtype: List[str]
            """
            if (len(s)<10): return []
            n = len(s)
            ans=[]
            dic={}
            for start in xrange(10):
                for i in xrange(start,n-10+1,10):
                    word=s[i:i+10]
                    if word in dic and dic[word]==1:
                        dic[word]+=1
                        ans.append(word)
                    elif word not in dic:
                        dic[word]=1
                    else:
                        continue
            return ans

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.