A simple array of integers is given. The problem is to detect if a pattern is repeatedly occurring in the array, and find the length of that pattern. For example, for {19, 6, 19, 6, 19, 6, 19, 6, 19, 6, 19, 6} pattern `{19, 6}` should be detected and its length is `2`. For {73, 7, 4, 73, 7, 4, 73, 7, 4, 73, 7, 4, 73, 7} pattern `{73, 7, 4}` should be detected and its length is `3`. *(at the end of the array there need not be the complete pattern, but the pattern should start at the beginning of the array)* For {73, 7, 4, 7, 2, 6, 7, 2, 7, 73, 9, 17, 7, 7} the whole array is the pattern and its length is `14`. Related links [MATLAB function seqperiod()][1] [SO question on cycle detection][2] [Related question on this site][3] [Wikipedia article on cycle detection][4] [1]: http://www.mathworks.com/help/signal/ref/seqperiod.html#zmw57dd0e102359 [2]: http://stackoverflow.com/questions/10441715/finding-a-repeating-sequence-at-the-end-of-a-sequence-of-numbers [3]: http://mathematica.stackexchange.com/questions/58098/find-patterns-in-a-list?rq=1 [4]: http://en.wikipedia.org/wiki/Cycle_detection