Simple, Easy to Understand Python solution beats 97.5%


  • 0
    G
    class Solution(object):
        def findRepeatedDnaSequences(self, s):
            """
            :type s: str
            :rtype: List[str]
            """
            res = set()
            sets= set()
            for i in range(len(s) - 9):
                if s[i:i + 10] in sets:
                    res.add(s[i:i + 10])
                else:
                    sets.add(s[i:i + 10])
            return list(res)
    

Log in to reply
 

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