One line easy understanding Python solution beat 96%


  • 0
    S
    return sum(len(os.path.commonprefix((s[:i][::-1], s[i:]))) + len(os.path.commonprefix((s[:i][::-1], s[i + 1:]))) + 1 for i in range(len(s)))
    

Log in to reply
 

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