<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) {
 	int size = s.length();
	if (size == 1)
		return false;
	if (size == 2)
		return(s[0] == s[1]);
	if (size == 3)
		return(s[0] == s[1] && s[1] == s[2]);
	vector<string>container;
	for (int i = 0, j = size - 1; i < j; i++, j--) {
		string left = s.substr(0, i + 1);
		string right = s.substr(j, size - j);
		if (left == right)
			container.push_back(left);
	}
	if (container.empty())
		return false;
	int cSize = container.size();
	int result = false;
	for (int i = 0; i < cSize; i++) {
		string current = container[i];
		string temp = "";
		int currentSize = current.length();
		int time = size / currentSize;
		for (int j = 0; j < time; j++) {
			temp += current;
		}
		if (temp == s) {
			result = true;
			break;
		}
	}
	return result;       
    }
};
407958