You could use patterns … To find the longest repeating subsequence try this …
{1, 3, 6, 17, 19, 3, 6, 5, 4, 2, 5, 6, 17, 19, 3, 6, 7, 5, 78, 100,
101} /. {___, Longest[y___], ___, Longest[y___], ___} :> y
This returns Sequence[6,17,19,3,6]
To find the shortest non-trivial (i.e., length 2 or greater) repeating subsequence try this …
{1, 3, 6, 17, 19, 3, 6, 5, 4, 2, 5, 6, 17, 19, 3, 6, 7, 5, 78, 100,
101} /. {___, Shortest[y___ /; Length[{y}] >= 2], ___,
Shortest[y___], ___} :> y
This returns Sequence[3,6]
Note: the answers are returned as Sequence objects. If, instead, you want ***
lists ***
returned change the final y
that appears after the :>
symbol to {y}
.
I can express the same solution in more verbose terms as …
{1, 3, 6, 17, 19, 3, 6, 5, 4, 2, 5, 6, 17, 19, 3, 6, 7, 5, 78, 100,
101} /. {BlankNullSequence[], Longest[y___], BlankNullSequence[],
Longest[y___], BlankNullSequence[]} :> y
{1, 3, 6, 17, 19, 3, 6, 5, 4, 2, 5, 6, 17, 19, 3, 6, 7, 5, 78, 100,
101} /. {BlankNullSequence[], Shortest[y___ /; Length[{y}] >= 2],
BlankNullSequence[], Shortest[y___], BlankNullSequence[]} :> y