<p>Given a string <code>s</code>, check if it can be constructed by taking a substring of it and appending multiple copies of the substring together.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abab&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong> It is the substring &quot;ab&quot; twice.
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;aba&quot;
<strong>Output:</strong> false
</pre>

<p><strong class="example">Example 3:</strong></p>

<pre>
<strong>Input:</strong> s = &quot;abcabcabcabc&quot;
<strong>Output:</strong> true
<strong>Explanation:</strong> It is the substring &quot;abc&quot; four times or the substring &quot;abcabc&quot; twice.
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>1 &lt;= s.length &lt;= 10<sup>4</sup></code></li>
	<li><code>s</code> consists of lowercase English letters.</li>
</ul>

class Solution {
public:
    bool repeatedSubstringPattern(string s) {
        std::list<std::string> substrings;
        std::string substring = "";
        for (char c : s) {
            substring.push_back(c);
            substrings.push_back(substring);
            if (substring.size() * 2 > s.size()) {
                break;
            }
        }
        substring = "";
        size_t point = 0;
        size_t repeat_count = 0;
        for (std::string ss : substrings) {
            repeat_count = 0;
            for (size_t i = 0; i < s.size(); i++) {
                if (ss[point] != s[i]) {
                    point = 0;
                    repeat_count = 0;
                    break;
                }
                point++;
                if (point == ss.size()) {
                    point = 0;
                    repeat_count++;
                }
            }
            if (repeat_count > 1 && point == 0) {
            return true;
            }
        }
        return false;
    }
};
414431