Question: https://leetcode.com/problems/repeated-dna-sequences/
Question Name: Repeated DNA Sequences
Simple brute force solution works.
1 2 3 4 5 6 7 8 9 | class Solution: # @param {string} s # @return {string[]} def findRepeatedDnaSequences(self, s): occurrence = {} for startIndex in xrange(len(s)-9): piece = s[startIndex : startIndex + 10] occurrence[piece] = occurrence.get(piece, 0) + 1 return [dna for dna in occurrence.keys() if occurrence[dna] > 1] |