String Similarity

  • + 0 comments

    **This is the best i could do , it gives the accurate answer but it failed only the time related test case, if some one could optimize this code plz go for it **

    def stringSimilarity(s):
    # Write your code here
    c = 0
    for i in range(1,len(s)):
    a = s[i:]
    for j in range(len(a)):
    if a[j] == s[j]:
    c += 1 
    else:
    break
    return c + len(s)