<commit_before>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
    }
}<commit_msg>Update problem 459<commit_after>package leetcode;

/**
 * https://leetcode.com/problems/repeated-substring-pattern/
 */
public class Problem459 {
    public boolean repeatedSubstringPattern(String str) {
        if (str.isEmpty() || str.length() == 1) {
            return false;
        }
        String sub1 = "" + str.charAt(0);
        String sub2 = "";
        int i = 0;
        i++;
        while (i < str.length() && i + sub1.length() <= str.length()) {
            sub2 = str.substring(i, i + sub1.length());
            if (sub1.equals(sub2)) {
                i += sub1.length();
            } else {
                sub1 += str.charAt(i);
                i++;
            }
        }
        return sub1.equals(sub2) && i == str.length();
    }

    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
//        System.out.println(prob.repeatedSubstringPattern("abcabca")); // false
//        System.out.println(prob.repeatedSubstringPattern("")); // false
//        System.out.println(prob.repeatedSubstringPattern("abac")); // false
//        System.out.println(prob.repeatedSubstringPattern("a")); // false
        System.out.println(prob.repeatedSubstringPattern("abababaaba")); // false
    }
}
{'fraction_non_alphanumeric': 0.15321011673151752, 'fraction_numerical': 0.017023346303501944, 'mean_word_length': 2.4112769485903813, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1674228', 'n_tokens_mistral': 617, 'n_tokens_neox': 591, 'n_words': 102}