I am looking for an effective search algorithm to get long the shortest repeating pattern in the collection (~ 2k integers), where my collection is made from this only repeating pattern (there is no noise between repeating patterns), but the last appearance of the pattern may be incomplete.
Examples: I have: [2,4,1, 2,4,1, 2,4,1, 2,4,1, 2,4,1]
I would like to get:[2,4,1]
I have: [21,1,15,22, 21,1,15,22, 21,1,15,22, 21,1,15]
I would like to receive:[21,1,15,22]
I have: [3,2,3,2,5]
I would like to receive: [](no template)
(spaces added for readability only)