Python solution giving Time limit Exceeded for second last test case.


  • 0
    D
    def findAnagrams(self, s, p):
            """
            :type s: str
            :type p: str
            :rtype: List[int]
            """
            
            l=list(s)
           
            
            return [i for i in xrange(len(l)-len(p)+1) if sorted(l[i:i+len(p)])==sorted(p)]
    
    

    Can anyone suggest ?


Log in to reply
 

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