Java solution, quite simple


  • 0

    '''
    public boolean repeatedSubstringPattern(String s) {
    int len = s.length(), i, j;
    for (i = 2; i <= len; i++) {
    for (j = 1; j < i; j++) {
    if (!s.substring(0, len/i).equals(s.substring(j*len/i, (j+1)*len/i))) break;
    }
    if (j == i) return true;
    }

        return (i-1)==len ? false: true;
    }
    

    '''


Log in to reply
 

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