Click4Ai

512.

Hard

Dynamic Time Warping

Problem Statement:

Given two time series datasets, calculate the similarity between them using the Dynamic Time Warping (DTW) algorithm.

Constraints:

  • Time series data is a 2D array with shape (n_samples, n_features).
  • Features in the time series data are expected to have a normal distribution.
  • Example:

    Suppose we have two time series datasets with two features. We want to calculate the similarity between them using the DTW algorithm.

    Test Cases

    Test Case 1
    Input: [[1, 2], [3, 4], [5, 6], [7, 8], [9, 10], [11, 12]]
    Expected: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
    Test Case 2
    Input: [[10, 20], [30, 40], [50, 60], [70, 80], [90, 100], [110, 120]]
    Expected: [1.0, 1.0, 1.0, 1.0, 1.0, 1.0]
    + 3 hidden test cases