One line Python


  • 0

    No KMP, use the built-in "replace" function to replace "search through a while loop"

    return any([True for i in range(1, len(string)/2+1) if (len(string) % i == 0 and string.replace(string[:i], '') == '')])
    

Log in to reply
 

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