466. Count The Repetitions

class Solution(object):
    
    def getMaxRepetitions(self, s1, n1, s2, n2):
        #http://www.cnblogs.com/grandyang/p/6149294.html
        #memoization: use dictionary to find loop where x*s1 contains y*s2, and each loop start with the same index of s2 
        #key=next_index, val=(s1_rep,s2_rep)
        #each item indicates, for s1_rep reps of s1, there are maximum s2_rep reps of s2 and the next_index of s2 to search for is next_index
        rep_count={} 
        s1_rep,s2_rep,next_index=0,0,0
        
        while s1_rep

你可能感兴趣的:(466. Count The Repetitions)