Java one-liner, no RegExp


  • 1
    public boolean repeatedSubstringPattern(String str) {
        return (str + str).indexOf(str, 1) < str.length();
    }
    

Log in to reply
 

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