Skip to content
DeepForgeby svx
All problems
MediumTime Seriests-168

Peak Timing Error

Problem

Compute the peak timing error as the absolute difference between the index of the maximum in forecast and in actual (the first occurrence wins on ties).

Return -1 if either series is empty.

Hint

Only the positions of the maxima matter here, not their heights.

Test cases

case 1
in: [[1,5,3],[1,2,6]]
expected: 1
case 2
in: [[3,1,2],[2,1,3]]
expected: 2
case 3
in: [[1,2,3],[3,2,1]]
expected: 2
case 4
in: [[],[]]
expected: -1
Starter codePython
def peak_timing_error(actual, forecast):
    # Your code here
    pass

4 test cases · run your code against them in the editor