Short python


  • 1
    Y

    One of the easier 'medium' difficulty. I thought we might be forced to use something more fancy.

    from collections import Counter
    class Solution(object):
        def findRepeatedDnaSequences(self, s):
            freq = Counter([s[i:i+10] for i in range(len(s)-9)])
            return [s for s in freq.keys() if freq[s] > 1]
    

Log in to reply
 

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