5 lines Python


  • 0
    L
        def findRepeatedDnaSequences(self, s):
            ctr = {}
            for i in range(len(s)):
                if i > len(s) - 10 : break
                else : ctr[s[i : i + 10]] = ctr.get(s[i : i + 10], 0) + 1
            return [k for k,v in ctr.items() if v > 1]
    

Log in to reply
 

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