How to find a cycle/repeats in a string?
<p>I need to detect a cycle/sequence in a string and return the first occurrence. How should I go about doing it?</p>

<p>Example :</p>

<pre><code>2 0 5 3 1 5 3 1 5 3 1
</code></pre>

<p>The first sequence to occur is <code>5 3 1</code>.</p>

<p>There is no rules. The sequence can be half the string length, for example </p>

<pre><code>5 3123 1231 231 31 231 41 452 3453 21 312312 5 3123 1231 231 31 231 41 452 3453 21 312312
</code></pre>

<p>The sequence is <code>5 3123 1231 231 31 231 41 452 3453 21 312312</code></p>
