<p>Given an array of positive integers <code>arr</code>, find a pattern of length <code>m</code> that is repeated <code>k</code> or more times.</p>

<p>A <strong>pattern</strong> is a subarray (consecutive sub-sequence) that consists of one or more values, repeated multiple times <strong>consecutively </strong>without overlapping. A pattern is defined by its length and the number of repetitions.</p>

<p>Return <code>true</code> <em>if there exists a pattern of length</em> <code>m</code> <em>that is repeated</em> <code>k</code> <em>or more times, otherwise return</em> <code>false</code>.</p>

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

<pre>
<strong>Input:</strong> arr = [1,2,4,4,4,4], m = 1, k = 3
<strong>Output:</strong> true
<strong>Explanation: </strong>The pattern <strong>(4)</strong> of length 1 is repeated 4 consecutive times. Notice that pattern can be repeated k or more times but not less.
</pre>

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

<pre>
<strong>Input:</strong> arr = [1,2,1,2,1,1,1,3], m = 2, k = 2
<strong>Output:</strong> true
<strong>Explanation: </strong>The pattern <strong>(1,2)</strong> of length 2 is repeated 2 consecutive times. Another valid pattern <strong>(2,1) is</strong> also repeated 2 times.
</pre>

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

<pre>
<strong>Input:</strong> arr = [1,2,1,2,1,3], m = 2, k = 3
<strong>Output:</strong> false
<strong>Explanation: </strong>The pattern (1,2) is of length 2 but is repeated only 2 times. There is no pattern of length 2 that is repeated 3 or more times.
</pre>

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

<ul>
	<li><code>2 &lt;= arr.length &lt;= 100</code></li>
	<li><code>1 &lt;= arr[i] &lt;= 100</code></li>
	<li><code>1 &lt;= m &lt;= 100</code></li>
	<li><code>2 &lt;= k &lt;= 100</code></li>
</ul>

class Solution {
public:
    bool check(vector<int>vec, vector<int>temp)
    {
        int n= vec.size();
        if(vec.size()!=temp.size()) return false;
        for(int i=0; i<n; i++)
        {
            if(vec[i]!=temp[i]) return false;
        }

        return true;
    }
    bool containsPattern(vector<int>& arr, int m, int k) {
        
        int n = arr.size(),cnt=0;

        for(int i=0; i<n; i++)
        {
            int j=i,cnt=1;
            vector<int> vec;
            while(j<n && j<m+i)
            {
                vec.push_back(arr[j]);
                j++;
            }


            while(j<n)
            {
                int k=j;
                vector<int> temp;

                while(k<n && k<m+j)
                {
                    temp.push_back(arr[k]);
                    k++;
                }

                if(check(vec,temp))
                {
                    cnt++;
                }
                else break;
                j=k;
            }

            if(cnt == k) return true;
        }

        if(cnt == k) return true;
        return false;
    }
};
12000