Let's say you have a list of similar sequences, such as
a a a a
a b a a a
x a a a a y
...
You want to detect a common aggregate of all these sequences, such as
x? a b? a a a y?
where operator ?
specifies that element is optional.
What algorithm would you use?