I have a sequence of values, and I want to know if it contains repeating subsequences of a certain minimum length. For instance:
1, 2, 3, 4, 5, 100, 99, 101, 3, 4, 5, 100, 44, 99, 101
Contains a subsequence 3, 4, 5, 100twice. It also contains a subsequence 99, 101twice, but this subsequence is double to take care of it.
Is there an effective algorithm for verifying the existence of such a subsequence? I am not particularly interested in placing sequences (although this would be useful for checking), I am primarily interested in the True / False answer, given the sequence and the minimum length of the subsequence.
Until now, my only approach is to search for brute force: for each element in the sequence, find all the other places where the element occurs (already at point O (N ^ 2)), and then go one step at a time from each place and see whether the next element matches, and keep going until I find a mismatch or find an appropriate subsequence of sufficient length.
Another thought that I had, but could not develop into a real approach, was to build a tree of all sequences, so that each number will be a node and a child of its previous number, if the node is already in the tree.