Alterable Similarity Join for Time Series
Dynamic Time Warping might be what you're looking for: it measures similarity between two time series based on the optimal alignment between the two sequences. For example point $i$ in sequence 1 might be better aligned with point $i+3$ in sequence 2 based on the evolution of the sequences (as opposed to Euclidean distance which would always compare $i$ in seq. 1 with $i$ in seq. 2). The alignment method is inspired by the Levenshtein edit distance method, which can be implemented efficiently with dynamic programming.
There are many software implementations available.