About this question

Dynamic Time Warping Distance

Medium · time_series · Quant Researcher interview question · dtw, dynamic_time_warping, time_series, pattern_matching, dynamic_programming

Dynamic Time Warping (DTW) is an algorithm for measuring similarity between two temporal sequences that may vary in speed. It finds the optimal non-linear alignment between sequences, making it useful in quantitative finance for pattern recognition in price series or comparing instruments with non-synchronous trading. The method uses dynamic programming to find the minimum-cost path through a matrix of pairwise distances. Task Implement the function dtw_distance(s: list, t_seq: list) -> float t