<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 n = s.size();
      if(n == 1) return false;
      vector<char> tmp;
      char start = s[0], end = s[n - 1];
      //tmp = string(1,start);
      tmp.push_back(s[0]);
      if(start == end)
      {
        int flag = 1;
        for(int i = 0; i < n;i ++)
        {
            if(s[i] != start)
            flag = 0;
        }
        if(flag == 1) return true;
      }
      for(int i = 1; i < n / 2; i++)
      {
          if(s[i] != end) 
          {
            tmp.push_back(s[i]);
          }
          else
          {
            string t;
            int len = i - 0 + 1;
            if(n % len != 0) continue;
            t.assign(s.begin(),s.begin()+i+1);
            int q = n/len;
            string f;
            while(q)
            {
                f = f + t;
                q--;
            }
            //string f = string(n/len,t);
            if(f == s) return true;
          }
      }
      return false;
    }
};
187893