Fast python solution with sets

  • 0
    class Solution(object):
        def findRepeatedDnaSequences(self, s):
            :type s: str
            :rtype: List[str]
            num_substr = len(s) - 10 + 1
            substr_set = set()
            ret_set = set()
            for i in xrange(num_substr):
                cur_str = s[i:i+10]
                if cur_str in substr_set:
            return list(ret_set)

    Beats 99% of python submissions!

Log in to reply

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