package leetcode;

/**
 * https://leetcode.com/problems/repeated-substring-pattern/
 */
public class Problem459 {
    public boolean repeatedSubstringPattern(String str) {
        // TODO
        return false;
    }

    public static void main(String[] args) {
        Problem459 prob = new Problem459();
        System.out.println(prob.repeatedSubstringPattern("abab")); // true
        System.out.println(prob.repeatedSubstringPattern("aba")); // false
        System.out.println(prob.repeatedSubstringPattern("abcabcabcabc")); // true
    }
}

@@ -177,36 +177,545 @@
     
-// TODO%0A        return false
+if (str.isEmpty() %7C%7C str.length() == 1) %7B%0A            return false;%0A        %7D%0A        String sub1 = %22%22 + str.charAt(0);%0A        String sub2 = %22%22;%0A        int i = 0;%0A        i++;%0A        while (i %3C str.length() && i + sub1.length() %3C= str.length()) %7B%0A            sub2 = str.substring(i, i + sub1.length());%0A            if (sub1.equals(sub2)) %7B%0A                i += sub1.length();%0A            %7D else %7B%0A                sub1 += str.charAt(i);%0A                i++;%0A            %7D%0A        %7D%0A        return sub1.equals(sub2) && i == str.length()
 ;%0A  
@@ -804,24 +804,26 @@
 oblem459();%0A
+//
         Syst
@@ -881,24 +881,26 @@
 )); // true%0A
+//
         Syst
@@ -962,16 +962,18 @@
 / false%0A
+//
         
@@ -1047,16 +1047,406 @@
 // true%0A
+//        System.out.println(prob.repeatedSubstringPattern(%22abcabca%22)); // false%0A//        System.out.println(prob.repeatedSubstringPattern(%22%22)); // false%0A//        System.out.println(prob.repeatedSubstringPattern(%22abac%22)); // false%0A//        System.out.println(prob.repeatedSubstringPattern(%22a%22)); // false%0A        System.out.println(prob.repeatedSubstringPattern(%22abababaaba%22)); // false%0A
     %7D%0A%7D%0A

Update problem 459