One option is a Granger causality test which a statistical hypothesis test for determining whether one time series is useful in forecasting another. One time series is said to Granger-cause another time series if the lagged values of one times series provide statistically significant information about future values of another time series.
This looks like a job for Dynamic Time Warping (DTW), as this algorithm calculates an optimal match between two given sequences. If you would like to implement it in Python (for example), I can recommend DTAIDistance. The documentation of this project is also very helpful if you want to understand this method in detail.