identify recurring/duplicate patterns as sub-arrays from a parent array
<p>I have a typical pattern searching problem where I need to identify where multiple patterns are appearing within an array and single them out.</p>

<p>ex: <code>['horse', 'camel', 'horse', 'camel', 'tiger', 'horse', 'camel', 'horse', 'camel']</code></p>

<p>function should return </p>

<pre><code>['horse', 'camel'], 
['horse', 'camel', 'horse'],
['camel', 'horse', 'camel'],
['horse', 'camel', 'horse', 'camel']
</code></pre>

<p>i.e. finding patterns that are repeating within an array which can become a sub-array, </p>

<p>Or the other way of defining is -> Find all the sub-arrays which are occurring more than 1 times in main array.</p>

<p>i.e. resulting arrays should have <code>length &gt; 1</code> -> </p>

<p><code>[1, 2, 3, 1, 2, 1, 4, 5]</code> => <code>[1,2,3]</code> and <code>[1,4,5]</code> both are sub-arrays but <code>[1,2,3]</code> is recurring/repeating sub-array NOT <code>[1,4,5]</code></p>

<p>Looking for a suitable efficient algorithm instead of brute-force looping solutions.</p>