I have an array of characters:
a b c x y d e f x y a b c t r e a b c
How can I find repetitive patterns of sizes 2 onwards?
The array needs to be traversed from the end. In the example I need to find patterns b c
, a b
, x y
and patterns of sizes 3: a b c
and x y z
. Along with the indices of matching chars.
So far I have tried to traverse the array backwards and find patterns:
for (int size = 2; size < aLT.size(); size++) {
for (int i = aLT.size() - 1; i >= 0; i--) {
// code here
}
}